获取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>

参考:

https://blog.csdn.net/qq_36285899/article/details/82867768

No qualifying bean of type xxx' available 的一种解决方法的更多相关文章

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

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

  2. 关于No qualifying bean of type [XXX.XXX] found for dependency 的一次记录

    异常开始于spring+springmvc+mybatis 注解配置,启动tomcat服务器出现No qualifying bean of type [com.***.service] found f ...

  3. Cannot load module file xxx.iml的两种解决方法

    一. 一种是点击左上角File,然后点击Invalidate Caches / Restart...,弹出对话框再点击Invalidate and Restart等待工程重新加载,问题就解决了. 二. ...

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

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

  6. 开发错误日志之No matching bean of type [xxx] found for dependency

    No matching bean of type [org.springframework.data.mongodb.core.MongoTemplate] found for dependency ...

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

  8. 【Spring】手动获取spring容器对象时,报no qualifying bean of type is defined

    手动获取容器对象时,报no qualifying bean of type is defined, 经过调查,发现手动获取的时候,该类所在的包必须经过spring容器初始化. 1.SpringConf ...

  9. Spring4.14 事务异常 NoUniqueBeanDefinitionException: No qualifying bean of type [....PlatformTransactionManager]

    环境为Spring + Spring mvc + mybatis:其中Spring版本为4.1.4 spring配置文件: <?xml version="1.0" encod ...

随机推荐

  1. 字节对齐#pragma pack

    这是给编译器用的参数设置,有关结构体字节对齐方式设置, #pragma pack是指定数据在内存中的对齐方式. #pragma pack (n)             作用:C编译器将按照n个字节对 ...

  2. icon组件

    iocn组件,小程序给我们提供了一些小图标,与微信的风格一致 iocn组件的属性: type:类型:string icon的类型: 属性值:success:成功   带背景的 success_no_c ...

  3. vue +ts 的一次踩坑日记

    在vue的方法里面写事件的时候比如写一个路由跳转,方法大概如下:  goBack1() {            console.log(this);            this.$router. ...

  4. 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_04 IO字节流_6_字节输出流写多个字节的方法

    一次写多个字节的方法 要在txt内显示100.49代表1 48 代表0 一次写多个字节 负数前两个组成一个中文.-65和-66 字节数组的一部分 写入字符串方法 当前用的编码格式是utf-8,utf- ...

  5. 测开之路八十七:HTML之a标签的用法

    初始化的HTML结构为,只需要在body里面加网页的标签和要显示的内容即可 <!DOCTYPE html><html lang="en"><head& ...

  6. python接口自动化:响应内容中json字符串对象的处理

    实现代码如下: import json #定义一个字典.一个列表.两个字符串({}中必须是双引号) di1={"} di2=[{"}] di3='{"name" ...

  7. idea的类头注释和方法注释的编辑

    一:配置类头注释 1:点击file,点击settings 2:点击editor,选择 file and code template ,然后看右侧部分点击include,之后选中File Header ...

  8. Linux QQ全新回归

    福音! 2019年10月24日,腾讯官方发布QQ Linux 2.0.0 Beta版本,告示着Linux QQ的回归. 2008年,腾讯曾推出QQ for Linux,但2009年之后就再没有更新过, ...

  9. mssql中quotename的作用

    quotename是保证字符原样输入到mssql中 eg: select * from '+QUOTENAME(@tbname) 用于所传字符为mssql保留字样

  10. herizai_CD2所做答案

    //herizai_CD1第一题 #include<iostream> #include<iomanip> using namespace std; void print1(i ...