SpringBoot 加入AOP后无法注入的解决办法

SpringBoot 开启AOP后 出现无法注入的问题 真是坑的很啊

提示错误

org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type

或者

java.lang.ClassCastException: com.sun.proxy.$Proxy12 cannot be cast to cn.edu.nuc.SpringTest.service.impl.DemoServiceImpl

解决办法:

在application.properties中添加配置

#true为使用CGLIB代理,false为JDK代理,默认为false
spring.aop.proxy-target-class=true
引以为戒啊!!!!!!!

你可能感兴趣的:(SpringBoot)