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.springframeworkgroupId>
    <artifactId>spring-aopartifactId>
    <version>4.0.5.RELEASEversion>
dependency>

正确的springboot maven依赖为

<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-aopartifactId>
dependency>

你可能感兴趣的:(项目经验)