Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate
阿新 • • 發佈:2018-12-25
在寫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>