1、在user-parent项目里面的pom.xml中配置如下
<!-- 管理继承的一些依赖,可以减少子类pom.xml的配置 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
2、在user-log中的pom.xml的配置如下
<<parent>
<groupId>com.baowei.user</groupId>
<artifactId>user-aggregation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../user-parent/pom.xml</relativePath>
</parent>
3、通过继承,来管理依赖关系
在子maven项目里面,可以减少配置文件
4、通过继承来管理常量
在子maven里面,重复的变量。只要在父maven项目里面,保留一份就可以了。子maven项目的都可以删除。 以减少配置文件。
5、注意
注意Maven的聚合和继承的区别:
Maven的聚合,找的是模块的位置。Maven的继承 ,找的是父类的pom.xml文件。