Spring Boot 2.0.0.M1错误引起:java.lang.ClassNotFoundException:org.springframework.aop.framework.AopProxyUtils

时间:2017-05-28 05:18:00

标签: spring spring-mvc spring-boot

我正在尝试新的Spring-boot 2.0.0.M1。我使用https://start.spring.io/初始化项目,只选择Web依赖项。

我在eclipse中打开了这个生成的项目,我在运行mvn clean install时遇到了错误:

    Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.boot.SpringApplicationRunListener : org.springframework.boot.context.event.EventPublishingRunListener
    at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:450)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:429)
    at org.springframework.boot.SpringApplication.getRunListeners(SpringApplication.java:415)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:323)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1278)
    at com.example.demo.DemoApplication.main(DemoApplication.java:12)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.context.event.EventPublishingRunListener]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/framework/AopProxyUtils
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:157)
    at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:446)
    ... 6 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/framework/AopProxyUtils
    at org.springframework.context.event.AbstractApplicationEventMulticaster.addApplicationListener(AbstractApplicationEventMulticaster.java:104)
    at org.springframework.boot.context.event.EventPublishingRunListener.<init>(EventPublishingRunListener.java:55)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:145)
    ... 7 more
Caused by: java.lang.ClassNotFoundException: org.springframework.aop.framework.AopProxyUtils
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

有没有人面临过类似的问题?请帮忙。

4 个答案:

答案 0 :(得分:1)

AutoProxyUtils类可用于org.springframework.aop.framework.autoproxy包而不是org.springframework.aop.framework包。检查classpath中是否提供了正确版本的spring-aop库。但是,它似乎是框架的错误。

我还有另外一项工作,

将spring-aop从启动依赖项中排除,如

<?php
    $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    if (strpos($url,'pages') !== false) {
        $url = trim($url, '%');
    }
?>

并使用新版本

分别添加spring-aop
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

答案 1 :(得分:1)

我遇到了同样的问题,我从.m2(Maven存储库)中删除了springaop文件夹并构建它。现在工作正常

答案 2 :(得分:1)

我在Spring Boot 1.5.4.RELEASE项目中遇到了同样的问题。我在项目中使用Amazon S3依赖项。我按照上述步骤进行操作,并提供了排除项,并添加了aop依赖关系,但未能解决问题。当我将spring boot版本从1.5.4.RELEASE更改为1.5.6.RELEASE时,它已解决。

答案 3 :(得分:0)

在pom.xml中包含spring-aop依赖项

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>5.0.1.RELEASE</version>
</dependency>