温馨提示×

maven怎么排除parent依赖

小亿
1475
2023-09-19 18:48:36
栏目: 编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

要排除Maven项目中的父依赖,你可以在子模块的pom.xml文件中使用标签,并使用元素指定父模块的路径。然后,在标签中排除不需要的依赖项。

下面是一个示例:

<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>child</artifactId>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>dependency</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>com.example</groupId>
<artifactId>excluded-dependency</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

在上面的示例中,标签指定了父模块的坐标和相对路径。然后,在标签中使用标签排除了不需要的依赖项。请确保在标签中使用正确的groupId和artifactId来排除相应的依赖项。

这样,当您构建子模块时,父模块的依赖不会被传递给子模块。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:maven怎么排除某个依赖

1