maven多项目管理,配置公共文件方式

设置继承方式,首先要在总项目的pom中加入如下配置,module值取得不是子项目的artifactId而是目录名称。
<modules>
    <module>childDirectoryName</module>
</modules>

其次每个子项目加入,默认继承上层目录中的pom。自定义指定继承关系,需要在parent添加relativePath
<parent>
    <groupId>com.parent</groupId>
    <artifactId>parent</artifactId>
    <version>2.0.0</version>
    <relativePath>..</relativePath>
</parent>

另外一种配置方式,通过配置引用建立关系,在依赖中加入一个type为pom的依赖即可。
<dependencies>
    <dependency>
         <groupId>com.parent</groupId>
         <artifactId>parent</artifactId>
         <version>2.0.0</version>
         <type>pom</type>
    </dependency>
</dependencies>

猜你喜欢

转载自primitive123.iteye.com/blog/1932215