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

相关文章
IDEA添加Swagger2:Parameter 0 of method linkDiscoverers in org. springframework hateoas.config.Hateoasconfiguration required a single bean, but 15 were found:
IDEA添加Swagger2:Parameter 0 of method linkDiscoverers in org. springframework hateoas.config.Hateoasconfiguration required a single bean, but 15 were found
|
3月前
IDEA lombok is undefined for the type
IDEA lombok is undefined for the type
|
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的错误
|
3月前
|
Java 测试技术 开发工具
IntelliJ IDEA中执行@Test单元测试时报错Class not found: "..."终极办法
IntelliJ IDEA中执行@Test单元测试时报错Class not found: "..."终极办法
202 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
184 0
|
JSON Java 数据库连接
IDEA在写Mybatis时遇到了Could not autowire. No beans of 'xxxx' type found 的错误提示
IDEA在写Mybatis时遇到了Could not autowire. No beans of 'xxxx' type found 的错误提示
193 0
|
Python
取消goloand,idea,pycharm等双击shift时出现的全局搜索
来回切换中英文输入法的时候,goland会弹出来一个搜索框,很不方便,现在要把那个弹出框禁用掉 File=> Settings=> Advanced Settings=> User Interface=> 选中“Disable double modifier key shortcuts”
323 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 重复代码的黄色波浪线取消设置
779 0
|
1月前
|
IDE Oracle Java
day4:JDK、IntelliJ IDEA的安装和环境变量配置
【7月更文挑战第4天】🏆本文收录于「滚雪球学Java」专栏,专业攻坚指数级提升,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&订阅!持续更新中,up!up!up!!
76 0