本文转自:http://blog.csdn.net/u012453843/article/details/54906905

1.问题描述

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

2. 原因

        原因可能有两个,第一个是IntellijIDEA本身工具的问题。第二个便是我们导入@Service包的时候导入包错误造成的

  第一种原因,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或其它可以忽略的级别。

针对第二种原因,解决方案当然是导入正确的包。首先我们来看下最容易导入的错误包,如下所示:

importcom.alibaba.dubbo.config.annotation.Service;
   正确的包应该是下面这个
importorg.springframework.stereotype.Service;
切记切记啊!!!!

IntelliJ Idea解决Could not autowire. No beans of 'xxxx' type found的错误提示的更多相关文章

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

    IntelliJ Idea 解决 Could not autowire. No beans of 'xxxx' type found 的错误提示哈,在使用 @Autowired 时,今天又遇一坑,这俩 ...

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

    问题描述 在idea中进行开发时,经常会遇见Could not autowire. No beans of 'xxxx' type found的错误提示,这样的是不影响程序编译和运行的,但是看起来会很 ...

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

    1.问题描述 在Idea的spring工程里,经常会遇到Could not autowire. No beans of 'xxxx' type found的错误提示.但程序的编译和运行都是没有问题的, ...

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

    1.问题描述 在Idea的spring工程里,经常会遇到Could not autowire. No beans of 'xxxx' type found的错误提示.但程序的编译和运行都是没有问题的, ...

  5. Could not autowire. No beans of 'xxxx' type found的错误

    在Idea的spring工程里,经常会遇到Could not autowire. No beans of 'xxxx' type found的错误提示.但程序的编译和运行都是没有问题的,这个错误提示并 ...

  6. IntelliJ Idea设置Could not autowire. No beans of 'xxx' type found

    1.问题描述 在Idea的spring工程里,经常会遇到Could not autowire. No beans of ‘xxxx’ type found的错误提示.但程序的编译和运行都是没有问题的, ...

  7. 解决 "Could not autowire. No beans of 'SationMapper' type found" 的问题

    网上查找的方法,附上原文链接:https://blog.csdn.net/Coder_Knight/article/details/83999139 方法1:在mapper文件上加@Repositor ...

  8. SpringBoot学习- 7、问题Could not autowire. No beans of 'xxxx' type found处理

    SpringBoot学习足迹 这个问题网上有好多同学都提到这个问题,代码可以运行,但是就是有红线,强迫症不能忍 自己试验下 1.增加一个final编译一下,再删掉就不会出红线了 public clas ...

  9. Could not autowire. No beans of 'TbItemMapper' type found. less... (Ctrl+F1) Checks autowiring prob

    Intellij Idea开发工具在@Autowired或者@Resource注入XxxMapper接口时报如下错误: Could not autowire. No beans of 'TbItemM ...

随机推荐

  1. 跟我学AngularJs:AngularJs入门及第一个实例

    林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankaka 摘要:主要给大家介绍了AngularJs及其特性,并以3个实例来做说明. 本教程使用Angul ...

  2. 使用自由软件Icarus Verilog Simulator进行仿真

    Icarus Verilog Simulator(http://iverilog.icarus.com/home)使用iverilog作为源代码编译器,编译生成vvp程序文本,使用vvp作为运行时引擎 ...

  3. 使用Java、Matlab画多边形闭合折线图

    由于写论文要将“哈密顿回路问题(TSP)”的求解中间结果表示出来,查了一下使用程序画多边形图形.现在在总结一下,这个图是“由给定节点首尾相连的”闭合多边形. 1.使用matlab作闭合多边形图 没有找 ...

  4. SQL Server Instance无法启动了, 因为TempDB所在的分区没有了, 怎么办?

    我的SQL 2014的虚拟机在迁移的时候, 存放TempDB的LUN被删掉了. 在虚拟机的操作系统启动了之后, SQL Server Instance却启动不起来了. 检查Event Log, 报错. ...

  5. Android导航抽屉-Navigation Drawer

    Google今年七月份的时候更新了他们的Google+应用,采用了新的导航方式并抛弃了navigationdrawer.一时之间,又引发了一系列关于NavigationDrawer利弊的讨论,不过对于 ...

  6. AngularJS 用 $http.jsonp 跨域SyntaxError问题

    必须添加参数:callback=JSON_CALLBACK , 才能进success方法,如下: $http.jsonp("https://request.address.json?call ...

  7. [Ajax] AJAX初体验之-在博客中添加无刷新搜索

    现在博客很流行,相信应该上网时间稍微长点的朋友都会在这或者在那的有一个自己的博客.对于一些有一定能力的朋友,可能更喜欢自己去下载一个博客程序来架设一个自己的博客,而不是使用一些博客网站提供的服务.而大 ...

  8. Diablo 3 Web API

    这是暴雪提供的WebAPI,能够通过网页的方式訪问玩家的用户信息.结构相当清晰,非常有借鉴价值. 应用JSON(JavaScript Object Notation)做数据交换,很好理解. 以我的暗黑 ...

  9. 如何监控执行的SQL语句?

    环境: SQL Server 2012. 打开SQL Server Profiler. 在菜单中选择New Trace, 连接上SQL Server. 在弹出的窗口中选择Event selection ...

  10. 【js】用正则表达式对文字进行局部替换

    比如有个字符串http://www.55188.com/thread-8306254-2-3.html,需要把8306254后面的2替换成其它数字,其它保持不变,该如何办呢?请看代码: var url ...