1

我正在尝试从 Maven 升级 spring-aop。我试图从我的 .m2 存储库中删除所有 Spring 文件,但是,当我运行 mvn dependency:tree 时,我看到 3.0.0.RC3 而不是 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 获得它?

4

3 回答 3

2

您的其他依赖项之一几乎肯定是传递性地引入不同版本的 spring。我确认如果我添加对 jersey-spring 的依赖项,我会得到一个旧版本的 spring-aop。您只需添加一个dependencyManagement部分即可修复它。为了演示这个问题,请尝试将以下内容放入一个空的 maven 项目中:

<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部分。这将是一个旧版本。删除对 j​​ersey-spring 的依赖,你又得到了正确版本的 spring-aop。

于 2012-07-04T20:15:52.120 回答
0

My guess would be that you may have dependency declared somewhere else (e.g. dependencyManagement section in this or parent project). Try to run mvn help:effective-pom to see the actual pom and then work from there.

于 2012-06-08T20:19:44.203 回答
0

Spring AOP 依赖于其他 jar 使用mvn dependency:tree来查看完整的细节。哪个罐子取决于其他罐子。

于 2014-07-23T10:01:46.020 回答