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

2022年8月10日12:14:57

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

引以为戒啊!!!!!!!

  • 作者:love13135816
  • 原文链接:https://blog.csdn.net/love13135816/article/details/80214646
    更新时间:2022年8月10日12:14:57 ,共 349 字。