2014-01-28 55 views
0

我有一個使用彈簧的項目。它採用3.1.1版,但是由於某種原因,我真的不知道,一些春天的文物被複制有兩個不同的版本。我從我的項目中查找所有pom.xml文件中的依賴項。我也使用依賴插件來確定這些依賴包括在哪裏。Maven的依賴不是在pom.xml中

在這裏,你有mvn dependency:tree

[INFO] | | \- org.springframework:spring-web:jar:3.1.1.RELEASE:compile 
[INFO] | |  +- aopalliance:aopalliance:jar:1.0:compile 
[INFO] | |  +- org.springframework:spring-beans:jar:3.1.1.RELEASE:compile 
[INFO] | |  +- org.springframework:spring-context:jar:3.1.1.RELEASE:compile 
[INFO] | |  | +- org.springframework:spring-aop:jar:3.1.1.RELEASE:compile 
[INFO] | |  | +- org.springframework:spring-expression:jar:3.1.1.RELEASE:compile 
[INFO] | |  | \- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile 
[INFO] | |  \- org.springframework:spring-core:jar:3.0.5.RELEASE:compile 

輸出的提取物,據我知道這意味着org.springframework:spring-core:jar:3.0.5.RELEASE:compile包括在org.springframework:spring-web:jar:3.1.1.RELEASE:compile

我解決這個包括範圍provided的依賴,但我需要知道爲什麼會這樣。

更新: 看來,當我評論下一個代碼時,戰爭中不包括罐子。

<dependency> 
    <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-rt-frontend-jaxws</artifactId> 
    <version>${cxf-version}</version> 
</dependency> 
... 
<properties> 
    ... 
    <cxf-version>2.4.2</cxf-version> 
    <spring.version>3.1.1</spring.version> 
</properties> 
+0

我真的不相信這兩個版本實際上在類路徑上,如果它具有相同的工件和groupId完全相同的依賴關係。 Maven應該管理它,只包含一個。到目前爲止,這一切看起來像預期的行爲,你試圖解決一個問題,即是不是一個真正的問題。 – Gimby

+1

嘗試使用'mvn dependency:tree -Dverbose'來獲取它是否實際包含的更多信息。 – Keppil

回答

0

spring-contextpom定義了的取得將版本相同的spring-context到dependency spring-core

<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-core</artifactId> 
    <version>${project.version}</version> 
    <scope>compile</scope> 
</dependency> 

因此,你必須在你的項目中dependencyManagement的地方,告訴Maven使用3.0.5.RELEASE,而不是3.1.1.RELEASE

看看你的勁歌。在dependencyManagement中一定有這樣的事情。

<dependencyManagement> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
     <version>3.0.5.RELEASE</version> 
    </dependency> 
</dependencyManagement> 

根據您的maven版本,它也可能使用dependency import

PS:同爲spring-asm

+0

沒有任何依賴關係管理 – esauro

0

如果我只添加org.springframework:spring-web:jar:3.1.1.RELEASE到項目,並通過mvn dependency:tree顯示樹出現以下的輸出:

[INFO] \- org.springframework:spring-web:jar:3.1.1.RELEASE:compile 
[INFO] +- aopalliance:aopalliance:jar:1.0:compile 
[INFO] +- org.springframework:spring-beans:jar:3.1.1.RELEASE:compile 
[INFO] +- org.springframework:spring-context:jar:3.1.1.RELEASE:compile 
[INFO] | +- org.springframework:spring-aop:jar:3.1.1.RELEASE:compile 
[INFO] | +- org.springframework:spring-expression:jar:3.1.1.RELEASE:compile 
[INFO] | \- org.springframework:spring-asm:jar:3.1.1.RELEASE:compile 
[INFO] \- org.springframework:spring-core:jar:3.1.1.RELEASE:compile 
[INFO]  \- commons-logging:commons-logging:jar:1.1.1:compile 

wher從來沒有org.springframework:spring-core:jar:3.0.5.RELEASEorg.springframework:spring-asm:jar:3.0.5.RELEASE參考。這意味着你有一個其他依賴其引入了或者正在使用一個dependencyManagement塊會覆蓋。

+0

謝謝,我正在尋找這種依賴關係,但我真的沒有看到它。 – esauro