当前位置:网站首页>IDEA 使用@Autowired注解报红的解决办法
IDEA 使用@Autowired注解报红的解决办法
2022-04-21 06:39:00 【欣慰丶缘纷】
整合SpringBoot工程时总会遇到一种情况,在Service中获取接口实例时使用@Autowired注解方式居然会报红。

但是这其实并不影响项目运行,但对于强迫症的我来说是不行的,后面找到了几种方法来解决这种问题。
方法1: 打开Settings -> Editor -> Inspections -> Spring -> Spring Core -> Code,找到Autowiring for bean class,将代码审查级别从Error修改为Warning

修改完成后就不报红了。

方法2:设置@Autowired中required=false

@Autowired在没有设置required的时候默认为true。
方法3:将@Autowired注解改为@Resource

这样就成功解决了!
版权声明
本文为[欣慰丶缘纷]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_42514758/article/details/114999134
边栏推荐
猜你喜欢

Leetcode 1557.可以到达所有点的最少点数目(Minimum Number of Vertices to Reach All Nodes)

(2022.1.31-2022.2.14)模板模式解析

PLSQL Developer 14安装详解

Steps for umlet beginners

状态模式(4.4-4.10)

Lecture de l'article: mesurer l'impact d'un accès DDOS réussi sur le comportement du client du serveur DNS géré

ReportViewer的RDLC打印报表怎么动态加载参数、图片、背景图

Flutter初体验

在vscode 中安装go插件并配置go环境以运行go

PLSQL developer 14 installation details
随机推荐
常用sql
写入数据进入磁盘文件代码示例如下:
Dip image smoothing
C#linq的group、count、sum,记一下
服务器部署svn环境
论文阅读:Supporting Early and Scalable Discovery of Disinformation Websites
php 格式化数字
Use C # to connect with Hangao highgo database to obtain user data table name, table structure, table name and primary key
实体类映射一个字段
Plsql14 software package download, localization and registration
Common weak passwords in network security devices
fiddler调换字体后界面缺少 恢复
H + background UI framework, click the button to create a new tab
C#中listView列自动适应缩放的完美效果
汇编语言——内存定位的方法
.net core 将错误抛出写入.txt文件
DeprecationWarning: NewId() is deprecated
Command-Line
树状数组
leetcode 203.移除链表元素