Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate

在写SpringAOP demo的时候报了这个错,demo是使用springboot搭建的,但是部分maven依赖复制网上的,导致出现这个问题是因为我的maven依赖引入错误。

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.context.event.EventPublishingRunListener]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object;

我在网上找的依赖… 很明显这个是spring的,而我的项目是springboot

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

正确的springboot maven依赖为

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-aop</artifactId>
</dependency>

版权声明:本文为Fmuma原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。