在父模块中:
mysql mysql-connector-java5.1.44
那么在子模块中只需要
mysql mysql-connector-java
1)Dependencies相对于dependencyManagement,所有生命在dependencies里的依赖都会自动引入,并默认被所有的子项目继承。
2)dependencyManagement里只是声明依赖,并不自动实现引入,因此子项目需要显示的声明需要用的依赖。如果不在子项目中声明依赖,是不会从父项目中继承下来的;只有在子项目中写了该依赖项,并且没有指定具体版本,才会从父项目中继承该项,并且version和scope都读取自父pom;另外如果子项目中指定了版本号,那么会使用子项目中指定的jar版本
org.springframework.boot spring-boot-starter-parent2.1.3.RELEASE
pom文件引用spring-boot-starter-parent后,并不会引入任何包,只是用来统一管理
build实例
src/main/java/ ***.xml org.apache.maven.plugins maven-resources-plugin2.6 org.springframework.boot spring-boot-maven-plugin2.0.5.RELEASE com.xx.xx repackage
3.1 Resources配置
... META-INF/plexus false ${basedir}/src/main/plexus configuration.xml **/*.properties ... ...
- resources
- 一个resources元素的列表。每一个都描述与项目关联的文件是什么和在哪里
- targetPath
- 指定build后的resource存放的文件夹,默认是basedir。
- 通常被打包在jar中的resources的目标路径是META-INF
- filtering
- true/false,表示为这个resource,filter是否激活
- directory
- 定义resource文件所在的文件夹,默认为${basedir}/src/main/resources
- includes
- 指定哪些文件将被匹配,以*作为通配符
- excludes
- 指定哪些文件将被忽略
- testResources
- 定义和resource类似,只不过在test时使用
directory和includes 为必填项
3.2 plugins和pluginManagement标签
loan-startup org.apache.maven.plugins maven-compiler-plugin3.8.0 org.apache.maven.plugins maven-source-plugin
1、两者的区别,和我们前面研究过的dependencies和dependencyManagement的区别非常类似。
plugins下的plugin是真实使用的,而pluginManagement下的plugins下的plugin则仅仅是一种声明,即你在项目中的pluginManagement下声明了插件,maven不会加载该插件。
3、子项目中可以对pluginManagement下的plugin进行信息的选择、继承、覆盖等。



