No qualifying bean of type xxx' available 的一种解决方法
获取bean
Class beanClass = Class.forName(event.className);
FilterEvent filterEvent = (FilterEvent)BeansContext.getWebApplicationContext().getBean(beanClass);
event.className为要获取的类名
1 反复检查类名是否正确 ok
2 检查包扫描配置是否正确 ok
3 检查bean 是否已注册 ok 检查之后确认bean没有问题
@Service
public class GDXMMXExtendEx implements FilterEvent { @PostConstruct
public void init(){
System.out.println("==============?");
} }
4 在代码其他地方获取bean ok
5 对比能获取到bean 与不能获取到bean 时的差异 发现
beanClass上的classloader 不一致
能获取到bean的classloader 为RestartClassLoader
不能获取到bean的classloader 为AppClassLoader
查询classloader的区别 发现 devtools 可能会影响classloader
去掉这个插件 一切正常了
<!-- <dependencies>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-devtools</artifactId>-->
<!-- <optional>true</optional>-->
<!-- </dependency>-->
<!-- </dependencies>
补充:20191217
打包的时候将文件屏蔽掉了
我的bean 叫FIAPITestService 下面这个排除刚好排除掉
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>application.yaml</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>ApplicationTest.class</exclude>
<exclude>**/*Test*.class</exclude>
<exclude>**/static/**</exclude>
<exclude>**/**/*.yaml</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
参考:
1 https://blog.csdn.net/qq_36285899/article/details/82867768
No qualifying bean of type xxx' available 的一种解决方法的更多相关文章
- spring注入时报错::No qualifying bean of type 'xxx.xxMapper'
做一个小项目,因为有 baseService,所以偷懒就没有写单独的每个xxService接口,直接写的xxServiceImpl,结果在service实现类中注入Mapper的时候,用的 @Auto ...
- 关于No qualifying bean of type [XXX.XXX] found for dependency 的一次记录
异常开始于spring+springmvc+mybatis 注解配置,启动tomcat服务器出现No qualifying bean of type [com.***.service] found f ...
- Cannot load module file xxx.iml的两种解决方法
一. 一种是点击左上角File,然后点击Invalidate Caches / Restart...,弹出对话框再点击Invalidate and Restart等待工程重新加载,问题就解决了. 二. ...
- Spring mvc 报错:No qualifying bean of type [java.lang.String] found for dependency:
具体错误: No qualifying bean of type [java.lang.String] found for dependency: expected at least 1 bean w ...
- 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 ...
- 开发错误日志之No matching bean of type [xxx] found for dependency
No matching bean of type [org.springframework.data.mongodb.core.MongoTemplate] found for dependency ...
- Spring Task Scheduler - No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined
1. Overview In this article, we are discussing the Springorg.springframework.beans.factory.NoSuchBea ...
- 【Spring】手动获取spring容器对象时,报no qualifying bean of type is defined
手动获取容器对象时,报no qualifying bean of type is defined, 经过调查,发现手动获取的时候,该类所在的包必须经过spring容器初始化. 1.SpringConf ...
- Spring4.14 事务异常 NoUniqueBeanDefinitionException: No qualifying bean of type [....PlatformTransactionManager]
环境为Spring + Spring mvc + mybatis:其中Spring版本为4.1.4 spring配置文件: <?xml version="1.0" encod ...
随机推荐
- datatbales的数据源类型(Data source types)
数据是复杂的,并且所有的数据是不一样的.因此 DataTables 中有很多的选项可用于配置如何获得表中的数据显示,以及如何处理这些复杂的数据. 本节将讨论 DataTables 处理数据的三个核心概 ...
- React Native商城项目实战09 - 个人中心自定义cell
1.新建组件CommonMyCell.js /** * 个人中心自定义cell */ import React, { Component } from 'react'; import { AppReg ...
- SDK使用NinePatch(.9)资源
.9资源是啥? .9图是一种可以拉伸的图片格式,当你把它用作背景图时,android系统会根据实际情况来拉伸图片资源.比如按钮的背景必须根据上面显示文字的长短作拉伸.NinePatch就是额外包含了一 ...
- loj#6487 基础 FFT 练习题
分析 仔细观察a[i],b[i]的数据范围 于是我们转为枚举所有a[i],b[i]的值 然后暴力即可 代码 #include<bits/stdc++.h> using namespace ...
- SpringBoot系列:五、SpringBoot使用Actuator
Actuator为springboot提供了运行状态监控的功能 通过集成它我们可以试试获取到应用程序的运行信息 首先,在pom.xml中引入起步依赖 <dependency> <gr ...
- 网页禁用表单的自动完成功能禁用密码自动填充autocomplete
网页中表单的自动完成功能,有时候很方便,但是有时候并不想让浏览器记忆表单,比如禁用密码域自动填充功能, 网页禁用表单的自动完成功能是由input元素的autocomplete属性控制,关闭表单的自动完 ...
- 测开之路一百零六:bootstrap布局
可以在html的head里面加一些说明 <meta http-equiv="X-UA-Compatible" content="IE=edge">& ...
- Hadoop实战内容摘记
Hadoop 开源分布式计算平台,前身是:Apache Nutch(爬虫),Lucene(中文搜索引擎)子项目之一. 以Hadoop分布式计算文件系统(Hadoop Distributed File ...
- Oracle 修改语言环境
Oracle数据库还是用英文的比较好,毕竟是外国人开发的.而且许多提示都是模板化 的,所以不懂英文,也不要怕,多Google就会了. 唉,安装Oracle 数据库时,手贱语言选择了中文和英语.结果使用 ...
- 【BASIS系列】SAP 中查看account登陆次数及时间的情况
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[BASIS系列]SAP 中查看account登 ...