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

简介:
1.问题描述

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

721070-20161223112659792-1241978017.png

2. 原因
spring auto scan配置,在编辑情况下,无法找不到对应的bean,于是提示找不到对应bean的错误。常见于mybatis的mapper,如下:

<!-- mapper scanner configurer -->
<bean id="mapperScannerConfig" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.adu.spring_test.mybatis.dao" />
    <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean>

3. 解决方案
降低Autowired检测的级别,将Severity的级别由之前的error改成warning或其它可以忽略的级别。

721070-20161223113553526-1283406981.png

相关文章
|
2月前
IDEA lombok is undefined for the type
IDEA lombok is undefined for the type
|
3月前
|
Java 测试技术 开发工具
IntelliJ IDEA中执行@Test单元测试时报错Class not found: "..."终极办法
IntelliJ IDEA中执行@Test单元测试时报错Class not found: "..."终极办法
62 0
|
3月前
|
Java Maven
idea执行maven打包失败:java.lang.TypeNotPresentException: Type org.springframework.boot.maven.RepackageMojo
idea执行maven打包失败:java.lang.TypeNotPresentException: Type org.springframework.boot.maven.RepackageMojo
|
9月前
|
Java Spring
2022年1月版IntelliJ Idea报错Could not autowire. No beans of ‘xxxx‘ type found的错误
2022年1月版IntelliJ Idea报错Could not autowire. No beans of ‘xxxx‘ type found的错误
|
10月前
|
JSON Java 数据库连接
IDEA在写Mybatis时遇到了Could not autowire. No beans of 'xxxx' type found 的错误提示
IDEA在写Mybatis时遇到了Could not autowire. No beans of 'xxxx' type found 的错误提示
158 0
|
Python
取消goloand,idea,pycharm等双击shift时出现的全局搜索
来回切换中英文输入法的时候,goland会弹出来一个搜索框,很不方便,现在要把那个弹出框禁用掉 File=> Settings=> Advanced Settings=> User Interface=> 选中“Disable double modifier key shortcuts”
248 0
取消goloand,idea,pycharm等双击shift时出现的全局搜索
idea springboot无法自动装配Could not autowire. No beans of ‘Xxx‘ type found.
idea springboot无法自动装配Could not autowire. No beans of ‘Xxx‘ type found.
idea springboot无法自动装配Could not autowire. No beans of ‘Xxx‘ type found.
IDEA 重复代码的黄色波浪线取消设置
IDEA 重复代码的黄色波浪线取消设置
402 0
|
Android开发
能让你的Intellij IDEA 起飞的几个设置(设置背景 字体 快捷键 鼠标悬停提示 提示忽略大小写 取消单行显示)(三)
能让你的Intellij IDEA 起飞的几个设置(设置背景 字体 快捷键 鼠标悬停提示 提示忽略大小写 取消单行显示)(三)
111 0
能让你的Intellij IDEA 起飞的几个设置(设置背景 字体 快捷键 鼠标悬停提示 提示忽略大小写 取消单行显示)(三)
能让你的Intellij IDEA 起飞的几个设置(设置背景 字体 快捷键 鼠标悬停提示 提示忽略大小写 取消单行显示)(二)
能让你的Intellij IDEA 起飞的几个设置(设置背景 字体 快捷键 鼠标悬停提示 提示忽略大小写 取消单行显示)(二)
能让你的Intellij IDEA 起飞的几个设置(设置背景 字体 快捷键 鼠标悬停提示 提示忽略大小写 取消单行显示)(二)