maven 父子关系
父项目中打包方式必须是pom 如 <packaging>pom</packaging>,父项目中使用<modules><module>msite-base</module></modules>指定子项目
子项目中使用 <parent>指定父项目,子项目继承父项目的大部分属性
父项目
<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.hlzt.msite</groupId> <artifactId>msite</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> <name>msite</name> <properties> <msite.version>0.0.1-SNAPSHOT</msite.version> </properties> <modules> <module>msite-base</module> </modules> <dependencyManagement> <dependencies> <dependency> <groupId>com.hlzt.msite</groupId> <artifactId>msite-base</artifactId> <version>${msite.version}</version> </dependency> </dependencies> </dependencyManagement> </project>
子项目
<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> <parent> <groupId>com.hlzt.msite</groupId> <artifactId>msite</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>msite-base</artifactId> <name>msite-base</name> <dependencies> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> </dependency> </dependencies> <build> <plugins> </plugins> </build> </project>