IntelliJ Idea 解决 Could not autowire. No beans of 'xxxx' type found 的错误提示
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 的错误提示相关推荐
- IntelliJ Idea解决Could not autowire. No beans of 'xxxx' type found的错误提示
解决方法:在Mapper层加入@Repository
- IntelliJ Idea取消Could not autowire. No beans of 'xxxx' type found的错误提示
2019独角兽企业重金招聘Python工程师标准>>> 1.问题描述 在Idea的spring工程里,经常会遇到Could not autowire. No beans of 'xx ...
- Could not autowire. No beans of 'xxxx' type found的错误提示
spring 集成mybatis 找不到 beans 查了很多网页,解决办法是: 在PersonMapper 上加 @Repository package zengmiaogen.csdn.cn.my ...
- 解决IDEA : Could not autowire. No beans of ‘xxxx‘ type found
错误信息 Could not autowire. No beans of 'xxxx' type found 导致原因及其解决办法 三种报错原因: 第一种:IDEA工具自身的缺陷,问题出在 sprin ...
- 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 ...
- 解决 Could not autowire. No beans of ‘UserDao‘ type found 问题
前言:今天在完善项目的时候发现使用@Autowired注入的Dao层依赖出现报错,但是不影响项目的运行,在此记录一下 问题 这个错误不影响项目运行,但是它看着很烦- 分析 Dao层代码: @Mappe ...
- Java--使用@Autowired报错Could not autowire. No beans of ‘XX‘ type found.
使用@Autowired时报错如下: Could not autowire. No beans of 'XXXX' type found. 1.检查下导入对象类的路径:注入的时候,导入的对象类路径不对 ...
- Could not autowire. No beans of ‘UserMapper‘ type found.
报红内容: 在这里可以发现userMapper处爆红,显示Could not autowire. No beans of 'UserMapper' type found.,但是在程序运行过程中并未影响 ...
- 使用 @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 ...
- SpringBoot报错:Could not autowire. No beans of ‘DiscussantMapper‘ type found
SpringBoot报错:Could not autowire. No beans of 'DiscussantMapper' type found 一.资源 @Mapper和@Repository注 ...
最新文章
- 关于jQuery获取Action返回的JSON数据 项目真实案例 记录(Struts2)
- Web-Scale Data
- 柑橘有了新农具:湖南30县农业主管与顶级专家共商“AIoT种柑橘”
- php 之 Final 关键字
- 一种PLC RS485 Modbus RTU无线联网的解决方案
- 不同品牌机中的“Fn”按钮功能定位汇总
- Nagios的安装与配置并实现飞信报警
- 从0开始实现自动化运维工具(一)
- 苹果电脑怎么进入安全模式教程
- b和kb的换算_kb和b换算(b kb mb换算)
- 基于深度学习的13种通用图像分类模型及其实现
- android os parcel,java.lang.RuntimeException:Parcel android.os.Parcel:...
- bzoj1050 [HAOI2006]旅行comf(并查集)
- stm32h7内存分配_【STM32H7教程】第9章 STM32H7重要知识点数据类型,变量和堆栈...
- android系统架构,文件目录
- wpf matlab混编,WPF(C#)与MATLAB混合编程
- 已经提交到gitlab上的代码如何撤回
- 某招聘网站“数据分析”相关岗位招聘信息爬取并分析
- 多页面实现-个人中心
- modelsim安装_Modelsim 重度使用者的故事:验证设计,软件与硬件的故事