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 本身工具的问题。

解决办法:

(1)不理它。

(2)在注解上加上:

@Autowired(required = false)
1
(3)降低 Autowired 检测的级别,将 Severity 的级别由之前的 error 改成 warning 或其它可以忽略的级别。

还有一个原因
这个博主没有遇到,友情粘贴!

第二个便是我们导入 @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>
1
2
3
4
5
解决办法:

错误导包 import com.alibaba.dubbo.config.annotation.Service;
1
正确的包应该是下面这个:

import org.springframework.stereotype.Service;
1
————————————————
版权声明:本文为CSDN博主「西瓜天尊」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/plpldog/article/details/91961101

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

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

    本文转自:http://blog.csdn.net/u012453843/article/details/54906905 1.问题描述 在Idea的spring工程里,经常会遇到Could not ...

  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. springMVC搭建分布式框架

    https://www.cnblogs.com/lr393993507/p/7652717.html https://www.cnblogs.com/Tpf386/p/10987931.html

  2. C++编译过程概述

    一 ---导读 想象成工厂要产出一个产品的过程,经过流水线上一步一步,不同的人的操作,然后经过整合,就得到了一个完整可用的产品. 二---编译过程图解 三---在linux中编程详解编译过程 当我们在 ...

  3. 效率工具 | 快速创建虚拟机,Vagrant真香!

    Vagrant 是一个基于Ruby的工具,主要用于创建和部署虚拟化开发环境.它以来于Oracle的开源VirtualBox虚拟化系统,通过使用 Chef创建自动化虚拟环境. Vagrant 主要的功能 ...

  4. MODBUS_RTU通信协议

    Modbus是一种串行通信协议,是Modicon公司(现在的施耐德电气Schneider Electric)于1979年为使用可编程逻辑控制器(PLC)通信而发表.Modbus已经成为工业领域通信协议 ...

  5. 浅谈ES6数组及对象的解构

    一.数组的解构,ES6的新特性,主要是方便操作数组,节省不必要的代码,提高代码质量. 上图例子中, example1: 之前想要获取数组中的值,只能挨个获取下标,然后取值 example2:ES6新特 ...

  6. Date、SimpleDateFormat以及Calendar

    Date类 毫秒值 java.util.Date:表示日期和时间的类 类Date表示特定的瞬间,精确到毫秒 日期转毫秒,号秒转日期 中国属于东八区,会把事件增加8个小时 1天 = 4 * 60 * 6 ...

  7. Facetoprocess_program_design

    面向过程程序设计 程序:计算机用可理解可执行的命令的集合. 过程:问题解决的步骤. 方法(函数) 结构化程序设计的基础 一.方法三要素 1 功能: 实现的功能(单一).简单.易维护 2 参数: (传入 ...

  8. python 3.6 导入c++dll所遇到的坑

    1 返回值在c++里面为const char*,python 接收实际上为int类型 原因:python默认返回值为int 解决方法: import ctypes import os CUR_PATH ...

  9. Mac M1原生(ARM64)Golang dev&debug

    前言 通过本文最终实现了在M1芯片的Mac mini上的Goland的开发,并通过编译源码解决了无法DEBUG的问题. Go 1.16版将正式支持Apple Silicon M1芯片,即arm64架构 ...

  10. 【JS学习】数组过滤方法的使用filter

    前言:本博客系列为学习后盾人js教程过程中的记录与产出,如果对你有帮助,欢迎关注,点赞,分享.不足之处也欢迎指正,作者会积极思考与改正. 使用效果: 可以返回参数函数为真的值 //情景:实现从stu数 ...