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   收藏:0   阅读:10232
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;

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!