版权声明:版权归JansonLin所有,转载请标明出处。 https://blog.csdn.net/Janson_Lin/article/details/83183118
一、聚合
在后期的开发都会是使用多模块开发,使用多模块开发需要使用maven的聚合。
1.1 代码聚合
<modules>
<module>模块1</module>
<module>模块2</module>
<module>模块3</module>
...
<module>模块N</module>
</modules>
1.2 例如
在这个模块中,manager是父模块,在manager的pom.xml中,代码如下
二、继承
2.1 继承代码配置
2.2 继承代码中定义的属性
在父模块中定义属性:
<properties>
<junit.version>4.12</junit.version>
</properties>
访问属性的方式为${junit.version}
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
2.3、父模块用dependencyManagement进行管理
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
</dependencies>
<dependencyManagement>