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 问题”的更多相关文章

  1. 解决: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 ...

  2. 解决 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type的问题

    具体错误如下: Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying be ...

  3. 解决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 ...

  4. 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 ...

  5. springmvc注入类 NoUniqueBeanDefinitionException: No qualifying bean of type [] is defined: expected single错误

    在springmvc中注入服务时用@Service 当有两个实现类时都标明@Service后则会出现异常: nested exception is org.springframework.beans. ...

  6. 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 ...

  7. 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问题.解决后在此记录一下. 解 ...

  8. 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< ...

  9. spring注入时报错::No qualifying bean of type 'xxx.xxMapper'

    做一个小项目,因为有 baseService,所以偷懒就没有写单独的每个xxService接口,直接写的xxServiceImpl,结果在service实现类中注入Mapper的时候,用的 @Auto ...

随机推荐

  1. Activity的创建及生命周期

  2. [python][nginx][https] Nginx 服务器 SSL 证书安装部署

    目录 前言 1 申请证书 2 Nginx 服务器 SSL 证书安装部署 2.1.准备 Nginx 环境 2.2 证书部署 2.3 Nginx 配置 3 最后 参考链接 前言 博主博客中的图片,使用的是 ...

  3. Qt:自动为class的所有属性生成getter、setter

    在类所在的.h文件中,右键类名,Refactor → Create Getter and Setter

  4. Java:List(一)——概述

    说明 在集合类中,List是最基础的一种集合--有序List. List的行为和数组几乎相同:List内部按照放入元素先后顺序存放,每个元素都可以通过索引确定自己的位置,List的索引和数组相同,都是 ...

  5. appium ios 相对坐标点击和控件滑动操作

    环境: 系统:ios 10.13.6 (17G12034) appium:1.14.0 xcode:10.1 iphone:iphone7 12.4 在尝试使用driver.tap([(a,b)],5 ...

  6. 使用Three.js实现神奇的3D文字悬浮效果

    声明:本文涉及图文和模型素材仅用于个人学习.研究和欣赏,请勿二次修改.非法传播.转载.出版.商用.及进行其他获利行为. 背景 在 Three.js Journey 课程示例中,提供了一个使用 Thre ...

  7. vue用ElementUI导出Excel表格

    import axios from 'axios'; import qs from 'qs'; import { message } from 'element-ui';   export const ...

  8. 8.Flink实时项目之CEP计算访客跳出

    1.访客跳出明细介绍 首先要识别哪些是跳出行为,要把这些跳出的访客最后一个访问的页面识别出来.那么就要抓住几个特征: 该页面是用户近期访问的第一个页面,这个可以通过该页面是否有上一个页面(last_p ...

  9. 接口自动化测试框架(Java 实现)

    目录 需求分析 开发设计 分层与抽象 技术选型 主要类设计 测试文件设计 工程目录设计 工程实现 github 地址 运行示例 需求分析 需求点 需求分析 通过 yaml 配置接口操作和用例 后续新增 ...

  10. myBatis plus 去除生成 controller

    ​ 由于我在网上没有找到答案, 所以分享给大家学习, 我也是第一次用 mybtis plus 的新生成器生成代码, 所以基础代码都是在官网复制所得. 在这里也支持大家在解决不了问题时, 可以试着看看源 ...