我有一個使用彈簧的項目。它採用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>
我真的不相信這兩個版本實際上在類路徑上,如果它具有相同的工件和groupId完全相同的依賴關係。 Maven應該管理它,只包含一個。到目前爲止,這一切看起來像預期的行爲,你試圖解決一個問題,即是不是一個真正的問題。 – Gimby
嘗試使用'mvn dependency:tree -Dverbose'來獲取它是否實際包含的更多信息。 – Keppil