@Autowired 注解用在方法与属性上

private ValueOperations, String> redisOperations
@Autowired
public void setValueOperations(StringRedisTemplate stringRedisTemplate) {
    this.redisOperations = stringRedisTemplate.opsForValue();
}
 
  

首先:@Autowired 与@Resource 的区别:参考https://blog.csdn.net/angus_17/article/details/7543478

其次:是因为我错误的用法导致springboot项目一直报找不到对应依赖的错;@Autowired 与@Resource针对同一个bean 只需要注解一个,我是在set方法上加了@Autowired后,又在属性上添加了@Resource注解。

你可能感兴趣的:(error,基础知识)