没有在service实现类的方法上加@Cacheable注解之前一直没有报错,加了之后就报如下错误,最后找到原因是在其他类里注入了这个加了注解的实现类,改成注入该实现类实现的接口类之后就不报错了。
报错:
2019-08-01 09:20:48.631 [ERROR] o.s.b.d.LoggingFailureAnalysisReporter -
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'honeypotServiceImpl' could not be injected as a 'com.yufeng.honeypot.service.impl.HoneypotServiceImpl' because it is a JDK dynamic proxy that implements:
com.yufeng.honeypot.service.HoneypotService
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.
修改前:

HoneypotServiceImpl就是加了@Cacheable注解的类,继承了HoneypotService。
修改后:

SpringBoot整合Redis注解报错解决
在尝试使用SpringBoot结合Redis的注解时遇到了一个问题,错误信息显示bean 'honeypotServiceImpl' 无法注入为'HoneypotServiceImpl',因为它是一个实现了'HoneypotService'接口的JDK动态代理。解决方案包括考虑将bean注入为其接口之一,或者通过设置@EnableAsync和/or @EnableCaching的proxyTargetClass=true来强制使用CGLib代理。
3691

被折叠的 条评论
为什么被折叠?



