有3个项目。B依赖于A,C依赖于A和B。A和B都依赖于版本1的包P,即P1。现在C引入P的另一个版本,命名为P2。
依赖树可能看起来像
P1 P1
^ ^
| |
A <- B
^ ^
\ /
\ /
C -> P2
为了避免 P 冲突,我决定通过修改pom.xml
A 和 B 来修剪 P1。但是奇怪
的事情发生了:当我mvn eclipse:eclipse
在 C 中运行时,我发现它仍然试图解决 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。
哪里不对了?
更新
我终于弄清楚出了什么问题:请参阅答案。