@Resource
private RedisTemplate<String, Object> redisTemplate;
@Autowired
private RedisTemplate<String, Object> redisTemplate;
采用注解时,不能用Autowired
原因
If you add a @Bean of your own of any of the auto-configured types it will replace the default
(except in the case of RedisTemplate the exclusion is based on the bean name ‘redisTemplate’ not its type).
意思是,当你需要用自定义bean RedisTemplate时,不能按类型装配,需要按名称…貌似这样