遇到过的问题之“解决 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# 集合】Hash哈希函数 |散列函数|摘要算法
希函数定义 哈希函数(英語:Hash function)又称散列函数.散列函数.摘要算法.单向散列函数.散列函数把消息或数据压缩成摘要,使得数据量变小,将数据的格式固定下来.该函数将数据打乱混合,重新 ...
- 【C# 程序集】.net core 3.0中动态卸载|卸载程序集
原文:https://docs.microsoft.com/zh-cn/dotnet/core/dependency-loading/understanding-assemblyloadcontext ...
- Oracle数据库常用命令整理
转至:https://blog.csdn.net/creativemobile/article/details/8982164 1监听 (1)启动监听 lsnrctl start (2)停止监听 l ...
- Centos6/7系统基础配置-从零到无
转至:https://www.cnblogs.com/Pigs-Will-Fly/p/13855300.html 目录 前言 系统配置 文档作用 一.Centos 6.X 系列配置 1.1 主机名 ...
- Spark分区数、task数目、core数目、worker节点数目、executor数目梳理
Spark分区数.task数目.core数目.worker节点数目.executor数目梳理 spark隐式创建由操作组成的逻辑上的有向无环图.驱动器执行时,它会把这个逻辑图转换为物理执行计划,然后将 ...
- 小白文-SpringMVC-解读DispatcherServlet源码
SpringMVC 学习完Spring框架技术之后,差不多会出现两批人: 一批是听得云里雾里,依然不明白这个东西是干嘛的: 还有一批就是差不多理解了核心思想,但是不知道这些东西该如何去发挥它的作用. ...
- PromQL全解析
PromQL(Prometheus Query Language)为Prometheus tsdb的查询语言.是结合grafana进行数据展示和告警规则的配置的关键部分. 本文默认您已了解Promet ...
- mysql什么时候会发生file sort
看了网上很多排名很靠前的博客,发现好多都讲错了!我开始按照博客来,没有怀疑,直到自己试了一下才发现是错的. file sort在面试中有时候会问到,这个其实挺能区分是不是真的了解order by的执行 ...
- Mysql8.0.17忘记密码情况下重置密码
1.以管理员身份打开命令窗口cmd,输入命令: net stop mysql 2.开启跳过密码验证登录的mysql服务,输入命令 mysqld --console --skip-grant-table ...
- numpy: np.logical_and/or/not (逻辑与/或/非)+python3-曲线拟合(polyfit/polyval)
可以用拟合两个变量之间的关系,然后根据一个变量,去推测出另外一个变量的推测值