遇到过的问题之“解决 No qualifying bean of type 问题”
1.问题
解决 No qualifying bean of type 问题

2.思路:
1 检查是否添加了对应注解
2 检查配置是否正确,扫描包名, 类名及id是否正确
一 . 传统SSM项目
ssm项目,出现“No qualifying bean of type found for dependency ***”错误,最后定位到该bean,仔细检查,
1 首先检查是否在类上添加了对应的注解,如:@Controller @Service @Reporsitry @Component

2 然后检查配置文件,发现有没有扫描到相应的包,在配置文件中加上该包

<context:component-scan base-package=
<context:component-scan base-package="com.ayh.order" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>
再如:在applicationContext-Service.xml中,有没有配置所注入service
applicationContext-Service.xml: <bean id="orderServiceImp" class="com.it.service.imp.OrderServiceImp"></bean>
3 是否有jar包依赖冲突
如:jpaj的jar包冲突
二 . spring boot项目
@Autowired - No qualifying bean of type found for dependency
1 . 主要就是检查是否在对应的类上添加了注解如:@Controller @Service @Reporsitry @Component
我的是在ReturnCycleReportJobHandler这里没有加入:@Component

2 . 启动类所在的位置是否在其他被扫描类的包的前面
如:启动类要在order包.其他类在下一级包

以下为根据具体选用情况而定, 多用优先级的顺序问题
1 .是否使用在具体mapper上有到 @Mapper
2 . 是否使用在application文件中
mybatis:
type-aliases-package: com.ayh.order.pojo
mapper-locations: com.ayh.order.mappers
3 .是否使用在启动类上用到了@MapperScan(value="com.ayh.order.mappers")
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@MapperScan(value = "com.ayh.order.mappers")
public class OrderApplication {
原文:https://blog.csdn.net/u010565545/article/details/100066824
遇到过的问题之“解决 No qualifying bean of type 问题”的更多相关文章
- 解决:No qualifying bean of type [org.springframework.jdbc.core.JdbcTemplate] found for dependency
错误: Description: Field jdbcTemplate in com.gwd.dao.impl.IUserDaoImpl required a bean of type 'org.sp ...
- 解决 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type的问题
具体错误如下: Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying be ...
- 解决spring-test中Feign问题: No qualifying bean of type 'org.springframework.cloud.openfeign.FeignContext' available
问题现象: 启动测试类(含通过Feign远程调用的组件),报错: No qualifying bean of type 'org.springframework.cloud.openfeign.Fei ...
- No qualifying bean of type [com.shyy.web.service.TreeMapper] found for dependency
异常信息: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.sp ...
- springmvc注入类 NoUniqueBeanDefinitionException: No qualifying bean of type [] is defined: expected single错误
在springmvc中注入服务时用@Service 当有两个实现类时都标明@Service后则会出现异常: nested exception is org.springframework.beans. ...
- spring异步执行报异常No qualifying bean of type 'org.springframework.core.task.TaskExecutor' available
最近观察项目运行日志的时候突然发现了一个异常, [2018-04-03 10:49:07] 100.0.1.246 http-nio-8080-exec-9 DEBUG org.springframe ...
- Caused by:org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type "" available: expected at least 1 bean which qualifies as autowire candidate
项目使用spring, mybatis.因为分了多个模块,所以会这个模块引用了其它模块的现在,结果使用Junit测试的时候发现有两个模块不能自动注入dao和service问题.解决后在此记录一下. 解 ...
- MyBatis Plus:No qualifying bean of type 'com.baomidou.mybatisplus.mapper.BaseMapper<?>' available: expected single matching bean but found 4
场景: 应用MyBatis Plus 和通用Mapper 继承自ServiceImpl实现对Service里的方法进行包装再处理. public interface IServiceBase2< ...
- spring注入时报错::No qualifying bean of type 'xxx.xxMapper'
做一个小项目,因为有 baseService,所以偷懒就没有写单独的每个xxService接口,直接写的xxServiceImpl,结果在service实现类中注入Mapper的时候,用的 @Auto ...
随机推荐
- C# 枚举器(enumerator)
总结: 1.枚举器就像是序列中的"游标"或"书签".可以有多个"书签",移动其中任何一个都可以枚举集合,与其他枚举器互不影响.用来遍历数据结 ...
- .net框架的详解
.net运行时 :Core,Xamarin,Mono或Framework? Core:面向所有平台 window .liniux .苹果mac .net Framework4.8:面向微软系统 已经 ...
- 为Visual Studio 2019设置 更改皮肤
下载主题插件:Color Themes for Visual Studio 安装插件 下载完成后 关闭vs2019 完成初始化,初始化完成后,再次打开软件进行配置. 卸载插件 点击卸载,然后关闭vs2 ...
- Python 中的闭包和自由变量
1.定义 在函数内部再定义一个函数,并且这个函数用到了外部函数的变量(LEGB),最后返回新建函数的函数名索引,那么将这样的能够访问其定义时所在的作用域的函数以及用到的一些变量称之为闭包.被引用的非全 ...
- AHUACM寒假集训VI(网络流)
luoguP2472.蜥蜴 传送门 题目大意: R × C ( 1 ≤ R , C ≤ 20 ) R\times C(1\leq R,C\leq20) R×C(1≤R,C≤20)的网格上,每个格子有一 ...
- drawable如何修改图片大小
这个问题刚开始遇到是导入图片太大,在网上找了许多教程大多都是采用setBounds()方法自己尝试许多次还是没成功,在经历了多达数个小时折磨后我找到两个方法1.在导入图片之前直接对图片进行修改大小.( ...
- Qt:QListWidget
0.说明 QListWidget指明一个基于Item的List Widget. 构造 QListWidget与QListView类似,都可以显示一列Item,区别在于前者可以往其中增删Item. QL ...
- Python:读取Excel 不带第一行标题
#根据第0到第1列进行重建 0-X 1-Y PX=sheet_name.col_values(0)[1:] PY=sheet_name.col_values(1)[1:] 读取的某一列后在后边加[1: ...
- c++刷leetcode记录
#include<iostream> #include<sstream> #include<vector> std::vector<int> split ...
- Python第二
今日内容概要 基本运算符 流程控制 字符编码 理论特别多.结论特别少 文件处理 今日内容详细 基本运算符 1.算数运算符 x = 1 y = 5 res = x + y #加 res1 = x - y ...