【发布时间】:2011-05-20 16:16:56
【问题描述】:
我有以下设置:
-
Master:有模块A和B -
A:声明对B、Master的依赖作为其父项 -
B:Master作为它的父节点
所以基本上Master 有一个父pom,它构建A 和B 其中A 依赖于B。
我的问题是我想将所有第 3 方依赖项放在 B 中(例如 JUnit 等)。但是当我这样做时,A 确实可以访问B 声明的依赖项。为什么会这样?我认为 maven 处理传递依赖关系。
这里是我的 poms 的 sn-ps,以防万一:
大师:
<modules>
<module>../A</module>
<module>../B</module>
</modules>
答:
<parent>
<groupId>com.project</groupId>
<artifactId>Master</artifactId>
<version>1</version>
<relativePath>../Master/pom.xml</relativePath>
</parent>
...
<dependency>
...
<artifactId>B</artifactId>
...
</dependency>
乙:
<parent>
<groupId>com.project</groupId>
<artifactId>Master</artifactId>
<version>1</version>
<relativePath>../Master/pom.xml</relativePath>
</parent>
...
<dependency>
...
<artifactId>JUnit</artifactId>
...
</dependency>
为什么A 不能访问 JUnit?
【问题讨论】:
标签: java maven-2 jakarta-ee