假设我正在开发依赖于项目 B 和 JUnit-11 的项目 A。
A -> junit-11 and B
项目 B 依赖于项目 C 和 JUnit-8。但它已经打包,我无法控制修改它的内容。
B -> junit-8 and C
项目 C 也依赖于 jUnit-8。
C -> junit-8
现在,问题是当我尝试构建我的项目(项目 A)时,它也得到 jUnit-8,这会破坏编译。当在我的 pom.xml 中定义它时,我可以排除项目 B 对 jUnit-8 的依赖性,但这不会传播到项目 C 的依赖性。因此,jUnit-8 仍然被下载并破坏了我的项目。
这里是相关的 pom.xml:
Project A (My Project) :pom.xml:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>B</groupId>
<artifactId>B</artifactId>
<version>1.0</version>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</dependency>
</dependencies>
Project B (Existing project):pom.xml:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8</version>
</dependency>
<dependency>
<groupId>C</groupId>
<artifactId>C</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
Project C (Existing project):pom.xml:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8</version>
</dependency>
</dependencies>
关于如何定义在所有子依赖项中排除 jUnit-8 的递归排除的任何建议?
最佳答案
也许你应该使用 Dependency Management在你的 pom.xml 中
关于java - Maven递归依赖排除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27852919/