前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >idea 引用 @Autowired 报错 Could not autowire 的情况

idea 引用 @Autowired 报错 Could not autowire 的情况

作者头像
灰太狼学Java
发布2022-06-17 09:31:59
1.5K0
发布2022-06-17 09:31:59
举报
文章被收录于专栏:Java学习驿站

问题

当我们在开发时使用 @Autowired 注入时 idea 报错: Could not autowire. No beans of ‘xxx’ type found. 但项目仍然是不受影响的,若将其更换成 @Resource 后正常,为了能让报错消失,提供以下解决方案。

方案

  1. 老版本 idea:File -> Settings -> Editor -> Inspections -> Spring -> Spring Core -> Code -> 将 Autowiring for Bean Class 的 Severity 的级别从 Error 降为 Warning,报错即可消失。
  1. 新版本 idea:File -> Settings -> Editor -> Inspections -> Spring -> Spring Core -> Code -> 将 Incorrect injection point autowiring in Spring bean components 的 Severity 的级别从 Error 降为 Warning,报错即可消失。
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 问题
  • 方案
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档