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 ...
随机推荐
- CSS札记(一):CSS选择器
一.语法规则 选择器{ 属性1:属性值1; 属性2:属性值2; ...... } /*注释*/ 二.如何在html中应用CSS 1. 外部引用css文件 css文件:css/layout.css(cs ...
- Linux shell - 按时间和文件大小排序显示文件(ll)
在工作中有这样的情况,需要显示所有的文件,按照时间先后或者文件大小先后排序显示 命令:ls 1.按时间排序显示文件 test@> ll -rt 2.按文件大小排序显示文件(文件大小单位:k,M) ...
- 2014 ECML: Covariate-correlated lasso for feature selection (ccLasso)
今天看了一篇 ECML 14 的文章(如题),记录一下. 原文链接:http://link.springer.com/chapter/10.1007/978-3-662-44848-9_38 这篇文章 ...
- 类TreeSet
/* * TreeSet能够对元素按照某种规则进行排序 * * 排序有2种方式 * A自然排序 * B比较器排序 * */ import java.util.TreeSet; /* * TreeSet ...
- 券商VIP交易通道
打新不成就炒新.随着新股发行上市的再次重启,巨大的获利机会引来投资者的争相竞逐,可并非所有投资者都能抢到新股筹码.“每天都在涨停板追这些新股,但从来没有买到过.”证券时报记者在采访中听到不少中小散户如 ...
- 【BASIS系列】SAP 批量锁住用户和TCODE的方法
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[BASIS系列]SAP 批量锁住用户和TCOD ...
- 应用安全-CMF/CMS漏洞整理
CMS识别 云悉 http://whatweb.bugscaner.com/batch.html CakePHP CakePHP <= / Cache Corruption Exploit 2 ...
- 003/node.js--代理服务(解决跨域问题)
业务描述: 1.web前端发送http请求 2.web后端为https协议 如何保证web前端发送http请求到web后端(跨域问题:域名不一致即跨域), 因此用node.js写了个代理服务,转发前端 ...
- 前端005/React生命周期
ES6中React生命周期 一.React生命周期 React生命周期主要包括三个阶段:初始化阶段.运行中阶段和销毁阶段. 在React不同的生命周期里,会依次触发不同的钩子函数. 二.React的生 ...
- Java 位运算符和移位运算符
一,运算的位运算符: & ~ | ^ 主要是对二进制的位计算 : & : 两个操作数中位都为1 结果才为1 其他结果为0 forExample: 128 ...