1. 程式人生 > >redis結合springboot 無法注入redisTemplate問題

redis結合springboot 無法注入redisTemplate問題

報錯:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.data.redis.core.RedisTemplate<java.io.Serializable, java.io.Serializable>' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

之前是,

@Autowired
private RedisTemplate<String, Object> redisTemplate;

 

改成

@Resource
private RedisTemplate<String, Object> redisTemplate;

 

解決。