假设我正在开发依赖于项目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中定义jUnit-8时,我可以排除项目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的递归排除有什么建议吗?
发布于 2015-01-09 10:39:46
也许您应该在pom.xml中使用Dependency Management
https://stackoverflow.com/questions/27852919
复制相似问题