本文介绍了Maven下载Spring-AOP 3.0.0.RC3而不是3.1.1.Final的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Maven升级spring-aop.我试图从.m2存储库中删除所有Spring文件,但是,当我运行mvndependency:tree时,我看到的是3.0.0.RC3而不是3.1.1.final ...

I am trying to upgrade spring-aop from Maven. I tried to delete all Spring files from my .m2 repo, however, when I run mvn dependency:tree I see 3.0.0.RC3 instead of 3.1.1.final...

依赖树:

[INFO] com.abercrombie.loyalty:LoyaltyProvider:war:0.0.1-SNAPSHOT
[INFO] +- org.springframework:spring-aop:jar:3.0.0.RC3: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-asm:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-context-support: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
[INFO] +- org.springframework:spring-expression:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:3.1.1.RELEASE:compile
[INFO] |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-web:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:3.1.1.RELEASE:compile
[INFO] +- com.thoughtworks.xstream:xstream:jar:1.3.1:compile
[INFO] |  \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] +- com.ibm.db2:db2jcc:jar:2.10.113:compile
[INFO] +- com.ibm.db2:db2jcc_license:jar:2.10.113:compile
[INFO] +- org.hibernate:hibernate-core:jar:3.5.6-Final:compile
[INFO] |  +- antlr:antlr:jar:2.7.6:compile
[INFO] |  +- commons-collections:commons-collections:jar:3.1:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] |  +- javax.transaction:jta:jar:1.1:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.5.8:compile
[INFO] +- org.hibernate:hibernate-annotations:jar:3.5.6-Final:compile
[INFO] |  +- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
[INFO] |  \- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:compile
[INFO] +- commons-dbcp:commons-dbcp:jar:1.4:compile
[INFO] |  \- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] +- org.slf4j:slf4j-simple:jar:1.5.6:compile
[INFO] +- javassist:javassist:jar:3.12.1.GA:compile
[INFO] +- cglib:cglib:jar:2.2.2:compile
[INFO] |  \- asm:asm:jar:3.3.1:compile
[INFO] +- com.sun.xml.bind:jaxb-impl:jar:2.1.12:compile
[INFO] |  \- javax.xml.bind:jaxb-api:jar:2.1:compile
[INFO] |     +- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] |     \- javax.activation:activation:jar:1.1:compile
[INFO] +- com.sun.jersey:jersey-core:jar:1.11:compile
[INFO] +- com.sun.jersey:jersey-server:jar:1.11:compile
[INFO] \- com.sun.jersey.contribs:jersey-spring:jar:1.11:compile
[INFO]    \- com.sun.jersey:jersey-servlet:jar:1.11:compile

POM依赖项

<spring.version>3.1.1.RELEASE</spring.version>
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-aop</artifactId>
   <version>${spring.version}</version>
</dependency>
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-beans</artifactId>
   <version>${spring.version}</version>
</dependency>
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context</artifactId>
   <version>${spring.version}</version>
   </dependency>
<dependency>

如何使用3.1.1.Final获得它?

how do I get it using 3.1.1.Final?

推荐答案

您的其他依赖项之一几乎肯定是在传递中引入了其他版本的spring.我确认,如果我增加对jersey-spring的依赖,我会获得较旧版本的spring-aop.您可以通过添加dependencyManagement部分来修复它.为了演示该问题,请尝试将以下内容放入一个空的Maven项目中:

One of your other dependencies is almost definitely transitively pulling in a different version of spring. I confirmed that if I add a dependency on jersey-spring I get an older version of spring-aop. You can fix it by just adding a dependencyManagement section. To demonstrate the problem, try putting the following into an empty maven project:

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>3.1.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey.contribs</groupId>
        <artifactId>jersey-spring</artifactId>
        <version>1.11</version>
    </dependency>
</dependencies>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>
    </dependencies>
</dependencyManagement>

查看mvn dependency:tree的输出.您将看到正确的spring-aop版本.然后删除dependencyManagement部分.这将是一个较旧的版本.删除对jersey-spring的依赖关系,您将再次获得正确版本的spring-aop.

Look at the output of mvn dependency:tree. You will see the correct spring-aop version. Then delete the dependencyManagement section. It will be an older version. Delete the dependency on jersey-spring and you get the correct version of spring-aop again.

这篇关于Maven下载Spring-AOP 3.0.0.RC3而不是3.1.1.Final的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 12:32