码迷,mamicode.com
首页 > 编程语言 > 详细

spring-boot 启动时候 出现异常:The bean 'xxx' could not be injected as a 'xx.xxxx' because it is a JDK dynamic proxy that implements:

时间:2018-03-28 16:46:18      阅读:10232      评论:0      收藏:0      [点我收藏+]

标签:cin   aaa   could not   出现   nbsp   for   tcl   ble   resource   

The bean ‘xxxService‘ could not be injected as a ‘AaaXxxService‘ because it is a JDK dynamic proxy that implements: 


Action:  
  
Consider injecting the bean as one of its interfaces or forcing the use of CGLib-based proxies by setting proxyTargetClass=true on @EnableAsync and/or @EnableCaching.

查了半天,原来是因为把 @Autowired 换成了 @Resource

以前的代码是

@Autowired
private AaaXxxService xxxService;

修改后的代码

@Resource
private AaaXxxService xxxService;

这样就报错了。。

主要问题是名字和类名不一样导致 Resource 注入失败,但是刚好又有一个 xxxService 同名的类存在,就会报这个错误

解决方法就是 名字改成和类一样

@Resource
private AaaXxxService aaaXxxService;

 

spring-boot 启动时候 出现异常:The bean 'xxx' could not be injected as a 'xx.xxxx' because it is a JDK dynamic proxy that implements:

标签:cin   aaa   could not   出现   nbsp   for   tcl   ble   resource   

原文地址:https://www.cnblogs.com/romicLord/p/8664198.html

(3)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!