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

今天在搭建spring+reids框架时遇到No qualifying bean of type [org.springframework.data.redis.core.RedisTemplate]

时间:2018-04-06 20:22:06      阅读:3562      评论:0      收藏:0      [点我收藏+]

标签:process   AC   autowire   inject   spring   exception   field   技术   测试   

今天在测试RedisTemplate时,用spring无法注入RedisTemplate,junit测试报错。

技术分享图片

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.data.redis.core.RedisTemplate] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
... 69 more

将代码改成:

技术分享图片

测试成功。

今天在搭建spring+reids框架时遇到No qualifying bean of type [org.springframework.data.redis.core.RedisTemplate]

标签:process   AC   autowire   inject   spring   exception   field   技术   测试   

原文地址:https://www.cnblogs.com/huanlingjisi/p/8728565.html

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