获取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. Spring Cloud教程(八)云原生应用程序

    Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智能路由,微代理,控制总线).分布式系统的协调导致了样板模式, 使用Spring Clo ...

  2. WWDC2017-advanced_animations_with_uikit

    最后修改时间: 2017-12-1 官方视频链接 这个Session主要讲一下的几个内容: Basic(基础的): 动画工作原理 以及 动画如何计时 Interactive and Interrupt ...

  3. Hyperledger交易流程

    Hyperledger Fabric Network中的角色 在Hyperledger中,由三种类型的角色: Client:应用客户端,用于将终端用户的交易请求发送到区块链网络: Peers:负责维护 ...

  4. Qt中用QuaZip来压缩和解压缩文件

    1.简介 QuaZIP是使用Qt,C++对ZLIB进行简单封装的用于压缩ZIP以及解压缩ZIP的开源库.如果你的Qt项目当中用到了压缩以及解压缩ZIP的话你可以考虑选择使用它. 官方主页:http:/ ...

  5. ANativeWindow_fromSurface

    c++后台若使用ANativeWindow_fromSurface将surface转化为ANativeWindow: 需要头文件:#include <android/native_window_ ...

  6. OGG-DDL复制

    http://blog.sina.com.cn/s/blog_96d348df0102vg6q.html OGG目前只支持Oracle和TeraData的ddl复制,Oracle数据库能够支持除去数据 ...

  7. 裸BFS题若干

    1poj 3278 http://poj.org/problem?id=3278 #include<math.h> #include<algorithm> #include&l ...

  8. dependencies 和 starter

    以 spring-cloud-alibaba-dependencies-1.5.0.RELEASE 为例: <dependency> <groupId>com.alibaba. ...

  9. 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_05 IO字符流_4字符输出流的基本使用_写出单个字符

    写完之后不刷新,则没有数据.数据只是写如到了内存缓冲区中 必须要调用flush方法,把数据刷新过去 close关闭的时候也会把数据刷新到文件中.这里把flush注释了也是可以的

  10. winform控件CxFlatUI

    CxFlatUI https://github.com/HuJinguang/CxFlatUI    当前控件 AlertBox Button CheckBox DatePicker GroupBox ...