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;