IntelliJ idea在Spring配置无错误时,装配对象出现 Could not autowire. no beans of "XXX" type found
来源:互联网 发布:不同表格相同数据查找 编辑:程序博客网 时间:2024/06/06 11:41
博客地址: http://blog.csdn.net/u010334295/article/details/78076510
案例:本人在使用IntelliJ idea 2017.2 开发SSM应用,做Junit Test测试时,通过Resource注解装配DAO时出现了ERROR的错误提示(Could not autowire. no beans of "XXX" type found). 但是当时并未在意,因为单元测试能够正常运行,遂认为对象在mybatis-spring中其实是已正确装配的.
但在之后的Service层中通过Autowired装配DAO对象又重复出现该错误提示,同样在检查了spring和mybatis各配置项后确认并不是我配置的问题. 单元测试仍然通过. 但是作为一个有强迫症的程序员来说,单个项目中连续出现这种ERROR级别的提示是绝对接受不了的,于是开始查各种原因.
在查询了万能的百度之后,各位大牛们,一致Ctrl+C/V的结果, 告诉我是我自己太Naive. 于是我也想出去看看美国的华莱士是多么的厉害, 查遍stackoverflow,国际友人们也多碰到此问题, 仔细斟酌自己的代码后发现, idea的纠错机制在解析spring通过命名约定的方式进行配置时,支持的并不是太好. 所以该ERROR并不会实际影响到你的程序运行.
于是再次确认自己的包扫描路径正确后,对装配对象加上@SuppressWarnings("SpringJavaAutowiringInspection"), 装配方式则采用idea推荐的构造方法装配后,Autowired的WARNING和装配对象的ERROR警告双双解决. Resource装配时的警告也一并解决. 其实和某些文章中降低ERROR警告到WARNING类似. 但是这更合理恰当.
以下是解决图示:
该问题算是告一段落.
- IntelliJ idea在Spring配置无错误时,装配对象出现 Could not autowire. no beans of "XXX" type found
- IntelliJ Idea取消Could not autowire. No beans of 'xxxx' type found的错误提示
- IntelliJ Idea取消Could not autowire. No beans of 'xxxx' type found的错误提示
- IntelliJ Idea取消Could not autowire. No beans of 'xxxx' type found的错误提示
- IntelliJ Idea取消Could not autowire. No beans of 'xxxx' type found的错误提示
- IntelliJ Idea取消Could not autowire. No beans of 'xxxx' type found的错误提示
- IntelliJ Idea取消Could not autowire. No beans of 'xxxx' type found的错误提示
- IntelliJ Idea解决Could not autowire. No beans of 'xxxx' type found的错误提示
- Could not autowire. No beans of 'xxxx' type found的错误提示(IntelliJ Idea)
- IntelliJ Idea解决Could not autowire. No beans of 'xxxx' type found的错误提示
- IntelliJ Idea取消Could not autowire. No beans of 'xxxx' type found的错误提示
- IntelliJ Idea取消Could not autowire. No beans of 'xxxx' type found的错误提示(其实不是错误)
- IntelliJ Idea取消Could not autowire. No beans of 'xxxx' type found的错误提示(其实不是错误)
- Idea的spring工程里,经常会遇到Could not autowire. No beans of 'xxxx' type found的错误提示
- idea 出现Could not autowire. No beans of 'xxxxMapper' type found. 安装 Mybatis Plugin 插件
- IDEA下Spring项目报错-could not autowire. no beans of“” type found
- idea中mybatis+spring boot, mapper 提示Could not autowire. No beans of … type found解决办法
- intellij Idea报错Could not autowire. No beans of...
- js判断浏览器与版本号
- 基于rem的移动端布局注意事项
- 移动架构02_UML类图
- 【C++】 标准运算符
- 在一个千万级的数据库查寻中,如何提高查询效率?
- IntelliJ idea在Spring配置无错误时,装配对象出现 Could not autowire. no beans of "XXX" type found
- querystring
- 编程计算1*1+2*2+3*3+…….n*n;
- 奇异值分解(SVD) --- 线性变换几何意义
- 3、实验一结果
- Django blog
- spark_RDD数据操作
- storm(1.0.3)版本源码编译方法
- icml和nips等会议论文地址