0

我正在尝试编译一个 Spring 应用程序,其中ApplicationConfig文件@EnableAspectJAutoProxy anotation在尝试运行项目时遇到此错误:

Failed to instantiate [org.springframework.aop.aspectj.annotation.
 AnnotationAwareAspectJAutoProxyCreator]:
 Constructor threw exception; nested exception is    
 java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Around

我不得不说,当我删除上面的注释时,项目运行成功。

在互联网上阅读后,我想可能是因为库和 jar 文件的版本不兼容。

当我运行mvn dependency:tree输出如下:

[INFO]    task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
[INFO] [dependency:tree {execution: default-cli}]
[INFO] groupId:myProject:jar:1.0-SNAPSHOT
[INFO] +- junit:junit:jar:4.11:compile
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.3.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:4.2.6.RELEASE:compile (version m
anaged from 4.3.0.RELEASE)
[INFO] |  |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  +- org.springframework:spring-beans:jar:4.2.6.RELEASE:compile
[INFO] |  +- org.springframework:spring-context:jar:4.2.6.RELEASE:compile (versi
on managed from 4.3.0.RELEASE)
[INFO] |  +- org.springframework:spring-core:jar:4.2.6.RELEASE:compile
[INFO] |  +- org.springframework:spring-expression:jar:4.2.6.RELEASE:compile
[INFO] |  \- org.springframework:spring-web:jar:4.2.6.RELEASE:compile (version m
anaged from 4.3.0.RELEASE)
[INFO] +- org.aspectj:aspectjweaver:jar:1.8.9:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] \- org.aspectj:aspectjrt:jar:1.8.9:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds

这是pom.xml文件的内容:

 <dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.3.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.8.9</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
    </dependency>

    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.8.9</version>
    </dependency>
</dependencies>

问题:我不明白这个输出是说一切都很好,或者我的项目中可能存在一些不兼容,如果有如何解决它们?

4

1 回答 1

0
于 2016-07-02T03:29:04.450 回答