Maven子模块怎么去掉父模块的包

avatar
作者
猴君
阅读量:7

要在Maven子模块中去掉父模块的包,可以使用<exclusions>元素来排除父模块的依赖包。

在子模块的pom.xml文件中,找到父模块的依赖,并在该依赖的<dependencies>元素中添加<exclusions>元素。在<exclusions>元素中,指定要排除的父模块的包的groupId和artifactId。

例如,以下是一个子模块的pom.xml文件的示例,其中排除了父模块的一个依赖包:

<project> ... <parent> <groupId>com.example</groupId> <artifactId>parent-module</artifactId> <version>1.0.0</version> </parent> ... <dependencies> <dependency> <groupId>com.example</groupId> <artifactId>parent-module-dependency</artifactId> <version>1.0.0</version> <exclusions> <exclusion> <groupId>com.example</groupId> <artifactId>excluded-dependency</artifactId> </exclusion> </exclusions> </dependency> </dependencies> ... </project> 

在上面的示例中,parent-module-dependency是父模块的一个依赖包,通过在子模块的pom.xml文件中添加<exclusions>元素,并指定要排除的依赖包的groupIdartifactId,就可以在子模块中去掉父模块的该依赖包。

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!