使用 spring boot 时,@Autowired 注解 自动装配注入时,变量报红解决方法:

1、使用 @Resource 代替 @Autowired 注解,根据类型注入改为根据名称注入(建议)。

2、在 XXXMapper 上添加 @Repository 注解,告诉 spring 容器该类已经注册进容器了(建议)。
3、改变依赖注入的等级,IDEA 默认为了 error,可以通过以下设置,进行等级修改或是忽略或取消(不建议)
idea
---> Setting
---> Inspections
---> 搜索 spring bean
---> 找到 Spring Bean Autowired,
---> 把红色(Error)修改为黄色(Warning)
---> OK

