使用springboot集成redis的时候,启动项目报错:
The bean 'redisTemplate' could not be injected as a 'org.springframework.data.redis.core.RedisTemplate' because it is a JDK dynamic proxy that implements:
org.springframework.data.redis.core.RedisOperations
org.springframework.beans.factory.BeanClassLoaderAware
下面给出了action
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.
我们可以看出redisTemplate是使用JDK自带的动态代理创建的代理对象,下面action推荐使用CGLIb代理,需要我们设置proxyTargetClass=true。
我们在配置文件中添加下面配置:
spring.aop.proxy-target-class: true