项目场景: 提示: 自动注入的时候,报错 问题描述: 测试redis连接的时候idea提示报错 Could not autowire. No beans of 'RedisTemplate @Autowired private RedisTemplate<Integer,String> redisTemplate; 原因分析: 分析: @AutoWired 是spring自带的,默认对象必须存在,默认按照类型来装配。 @Resouce 是J2EE的注解,默认按照名称来装配 解决方案: 提示:将@Autowired换成@Resouce;