有3个项目。 B取决于A,C取决于A和B.A和B都取决于版本1的包P,即P1。现在C介绍P的另一个版本,将其命名为P2。如何在maven中解决这个奇怪的依赖关系?
的denpendency树可以看起来像
P1 P1
^ ^
| |
A <- B
^ ^
\ /
\/
C -> P2
为了避免P confilict,我决定修剪P1,通过修改A和B的pom.xml
但发生奇怪的
的事情:当我用C跑mvn eclipse:eclipse
,我发现它仍然尝试解决P1的依赖关系!
然后我仔细检查了每个项目。
In A: Re-check the pom.xml -> NO dependency of P1 , it won't resolve P1 !
In B: Re-check the pom.xml -> NO dependency of P1 , it won't resolve P1 !
In C: Re-check the pom.xml -> NO dependency of P1 itself , but it DOES resolve P1!
|
| - Comment out dependency of A: Resolve P1 !
|
| - Comment out dependency of B: Resolve P1 !
|
| - Comment out dependency of both A & B: Won't resolve P1 !
Finally, I make sure that other packages of A , B and C that depend on do not
depend on P1(Actually, P1 is a small SDK with limited usage, I'm sure other
packages won't denpend on it)
所以这里是奇怪的事情: 根据检查,似乎A或B介绍P1,但在A和B分别,我检查 ,并得出结论,无论是将推出P1。
有什么问题吗?
UPDATE
我终于弄清楚什么是错的:一看便知。
我不知道如何处理这个没有更多的细节。 'dependency:tree'的输出是什么? –
建立在命令行上吗? mvn清洁包吗? – khmarbaise
对于理解类路径,Eclipse是一个糟糕的IDE。一些其他的IDE,例如IntelliJ和NetBeans有更好的处理不同类路径的能力。测试与代码等等。所以你可能会遇到Eclipse本身的问题,而不是Maven问题。我会建议在其他IDE中检查类路径,以确认你正在做你认为正在做的事。我知道IntelliJ会在我自己使用它的时候给出正确的类路径,而且我可以肯定地告诉NetBeans也一样。 –