IntelliJ Idea 解决 Could not autowire. No beans of ‘xxxx’ type found 的错误提示

哈,在使用 @Autowired 时,今天又遇一坑,这俩波浪线是干啥子嘛:

然鹅,试了一下,控制台也不报错,可以正常运行,

数据也有:

于是,又再百度上找答案。。

问题分析

在 Idea 的 spring 工程里,经常会遇到 Could not autowire. No beans of ‘xxxx’ type found 的错误提示。但程序的编译和运行都是没有问题的,这个错误提示并不会产生影响。但红色的错误提示在有些有强迫症的程序员眼里,多多少少有些不太舒服。

问题原因其一

第一个是 Intellij IDEA 本身工具的问题。IDEA 可以理解 Spring 的上下文,这个是因为 它是 MyBatis 的接口,不认识

这个一共有 7 种解决方案

解决办法:

(1)在注解上加上:

@Autowired(required = false)

(2)使用 @Resource 替换 @Autowired

(3)在 MyBatis 接口上加上 @Repository 注解

(4)使用 Lombok,@RequireArgsContructor

(5)降低 Autowired 检测的级别,将 Severity 的级别由之前的 error 改成 warning 或其它可以忽略的级别。

(6)安装 MyBatis 插件

(7)构造器注入

更多文章链接

  • Java 爬坑记录

IntelliJ Idea 解决 Could not autowire. No beans of 'xxxx' type found 的错误提示相关推荐

  1. IntelliJ Idea解决Could not autowire. No beans of 'xxxx' type found的错误提示

    解决方法:在Mapper层加入@Repository

  2. IntelliJ Idea取消Could not autowire. No beans of 'xxxx' type found的错误提示

    2019独角兽企业重金招聘Python工程师标准>>> 1.问题描述 在Idea的spring工程里,经常会遇到Could not autowire. No beans of 'xx ...

  3. Could not autowire. No beans of 'xxxx' type found的错误提示

    spring 集成mybatis 找不到 beans 查了很多网页,解决办法是: 在PersonMapper 上加 @Repository package zengmiaogen.csdn.cn.my ...

  4. 解决IDEA : Could not autowire. No beans of ‘xxxx‘ type found

    错误信息 Could not autowire. No beans of 'xxxx' type found 导致原因及其解决办法 三种报错原因: 第一种:IDEA工具自身的缺陷,问题出在 sprin ...

  5. IDEA 报 「Could not autowire. No beans of ‘UserMapper‘ type found」错误解决方案

    IDEA 报 「Could not autowire. No beans of 'UserMapper' type found」错误解决方案 参考文章: (1)IDEA 报 「Could not au ...

  6. 解决 Could not autowire. No beans of ‘UserDao‘ type found 问题

    前言:今天在完善项目的时候发现使用@Autowired注入的Dao层依赖出现报错,但是不影响项目的运行,在此记录一下 问题 这个错误不影响项目运行,但是它看着很烦- 分析 Dao层代码: @Mappe ...

  7. Java--使用@Autowired报错Could not autowire. No beans of ‘XX‘ type found.

    使用@Autowired时报错如下: Could not autowire. No beans of 'XXXX' type found. 1.检查下导入对象类的路径:注入的时候,导入的对象类路径不对 ...

  8. Could not autowire. No beans of ‘UserMapper‘ type found.

    报红内容: 在这里可以发现userMapper处爆红,显示Could not autowire. No beans of 'UserMapper' type found.,但是在程序运行过程中并未影响 ...

  9. 使用 @Resource或@Autowire时 Idea报错Could not autowire. No beans of 'xxxService' type found. more..出现红色波浪线

    原博客:https://blog.csdn.net/qq_36802726/article/details/84026031 错误:  使用注解@Resource或者@Autowire intelli ...

  10. SpringBoot报错:Could not autowire. No beans of ‘DiscussantMapper‘ type found

    SpringBoot报错:Could not autowire. No beans of 'DiscussantMapper' type found 一.资源 @Mapper和@Repository注 ...

最新文章

  1. 关于jQuery获取Action返回的JSON数据 项目真实案例 记录(Struts2)
  2. Web-Scale Data
  3. 柑橘有了新农具:湖南30县农业主管与顶级专家共商“AIoT种柑橘”
  4. php 之 Final 关键字
  5. 一种PLC RS485 Modbus RTU无线联网的解决方案
  6. 不同品牌机中的“Fn”按钮功能定位汇总
  7. Nagios的安装与配置并实现飞信报警
  8. 从0开始实现自动化运维工具(一)
  9. 苹果电脑怎么进入安全模式教程
  10. b和kb的换算_kb和b换算(b kb mb换算)
  11. 基于深度学习的13种通用图像分类模型及其实现
  12. android os parcel,java.lang.RuntimeException:Parcel android.os.Parcel:...
  13. bzoj1050 [HAOI2006]旅行comf(并查集)
  14. stm32h7内存分配_【STM32H7教程】第9章 STM32H7重要知识点数据类型,变量和堆栈...
  15. android系统架构,文件目录
  16. wpf matlab混编,WPF(C#)与MATLAB混合编程
  17. 已经提交到gitlab上的代码如何撤回
  18. 某招聘网站“数据分析”相关岗位招聘信息爬取并分析
  19. 多页面实现-个人中心
  20. modelsim安装_Modelsim 重度使用者的故事:验证设计,软件与硬件的故事

热门文章

  1. 烂土豆搭配令牌窃取提权dll劫持搭配令牌窃取提权不带引号服务路径问题提权不安全的服务权限配置提权
  2. position:fixed;支持ie6,清除e6下抖动。
  3. 路由器内部到底是啥结构?不懂就不算网工人
  4. MySQL数据库知识的总结
  5. 软件测试笔记——如何测试一个矿泉水瓶?
  6. c语言scan例子,SCAN和C-SCAN算法图解
  7. 中国研修网计算机培训心得,网络研修培训心得体会(精选7篇)
  8. xenu死链接工具使用
  9. 11408考研复习规划
  10. AVFoundation照片/视频捕捉功能 小视频/直播