聚合:
在maven中,想要对多个项目进行install命令,将其安装到本地仓库中,必须对其依次执行install命令,maven中有种方式,可以将其放在一起运行,这种方式称之为聚合。
有三个项目:A项目、B项目、C项目,对其实现聚合,实现如下:
聚合方式的实现:
1、新建一个项目D
2、修改D项目的pom文件中的项目构件信息中的<packaging></packaging>标签,原来是jar,修改为pom
3、使用<modules>标签,并且进行install命令,pom文件中的modules标签配置如下:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.qw.hongxing</groupId>
<artifactId>D</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>D</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<modules><!-- 使用聚合的标签 -->
<module>../A</module><!-- 聚合的项目 -->
<module>../B</module>
<module>../C</module>
</modules>
</project>