我有一个使用spring的项目。它使用3.1.1版本,但由于某些原因我真的不知道,一些spring工件被复制成两个不同的版本。我在我的项目的所有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的依赖项,但我需要知道为什么会发生这种情况。
更新:当我评论下一段代码时,war中似乎没有包含jars。
<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>发布于 2014-01-28 12:51:08
spring-context pom使用与spring-context完全相同的版本定义了对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版本,也可能使用依赖项导入。
PS:同样适用于spring-asm
发布于 2014-01-28 12:52:09
如果我只向项目添加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从没有得到对org.springframework:spring-core:jar:3.0.5.RELEASE或org.springframework:spring-asm:jar:3.0.5.RELEASE的引用。这意味着您有一个其他的依赖项来引入该依赖项,或者您正在使用一个dependencyManagement块覆盖该依赖项。
https://stackoverflow.com/questions/21405791
复制相似问题