设置继承方式,首先要在总项目的pom中加入如下配置,module值取得不是子项目的artifactId而是目录名称。
其次每个子项目加入,默认继承上层目录中的pom。自定义指定继承关系,需要在parent添加relativePath
另外一种配置方式,通过配置引用建立关系,在依赖中加入一个type为pom的依赖即可。
<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>
本文介绍如何在Maven项目中设置多模块继承关系。包括在父模块中配置子模块目录,以及子模块如何指定继承关系。此外还介绍了通过依赖方式引入父模块pom文件的方法。
1283

被折叠的 条评论
为什么被折叠?



