Error creating bean with name 'hotWordServiceImpl': Unsatisfied dependency expressed through field '

来源:互联网 发布:o2o商城源码 编辑:程序博客网 时间:2024/06/02 01:12
错误Error creating bean with name 'hotWordServiceImpl': Unsatisfied dependency expressed through field 'redis'; 
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
'org.springframework.data.redis.core.RedisTemplate<java.lang.String, java.lang.String>' available: expected at 
least 1 bean which qualifies as autowire candidate. Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true),

@org.springframework.beans.factory.annotation.Qualifier(value=hotwordRedisTemplate)}

-------------------------------------------------------------------------------------------------------------------------

原因:调用的时候是这样写的

@Autowired
 @Qualifier("hotwordRedisTemplate")
 private RedisTemplate<String, String> redis;


但是接口定义是这样的

 @Bean(name = "hotwordRedisTemplate")
    public RedisTemplate<String, Object> cacheRedisTemplate() {

......

-------------------------------------------------------------------------------------------------------

修正:把标红的地方换成String就OK了

阅读全文
0 0