一个项目由多个子项目组成,每个子项目也是一个maven项目。每次打包需要打包每个子项目,很麻烦,其实可以通过配置一个顶级的pom.xml文件来解决这个问题,只需要打包顶层的maven项目,即可。如果一个项目有多个子项目的pom.xml文件,比如我的项目路径是这样的,项目结构如图,如果没有一个总的pom文件,则不能一次打包多个maven项目。
总的pom.xml内容,主要是在 models里面配置上需要编译打包的项目pom文件路径
<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.goldwind.stockright</groupId>
<artifactId>goldwindstockright</artifactId>
<version>2.0</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>evaluation-common</module>
<module>evaluation-service</module>
<module>holding-common</module>
<module>holding-service</module>
<module>investment-common</module>
<module>investment-service</module>
<module>privilege-common</module>
<module>privilege-service</module>
<module>third-common</module>
<module>third-party</module>
<module>sockright-ui</module>
</modules>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>