当前位置: 首页 > news >正文

SpringBoot监听器

1.寻找spring.factories配置文件对应的监听器,主要要写监听器的全路径名,不然反射会报错

 

 

 SpringBoot底层是如何读取META-INF/spring.factories的配置的?

1.遍历所有jar下的META-INF/spring.factories配置文件

2.读取配置文件下的所有属性,放入map

3.配置文件主要来源于,

3.1.开发者自己放的 

 

 3.2 spring-boot的配置文件 

3.spring-boot-autoconfiguration配置文件

读取完后放入缓存中,主要有13个大类,分别是:

org.springframework.context.ApplicationListener             2个值

======================spring-boot================================

org.springframework.boot.env.PropertySourceLoader           2个值
org.springframework.boot.SpringApplicationRunListener       1个值
org.springframework.boot.SpringBootExceptionReporter        1个值
org.springframework.context.ApplicationContextInitializer   4个值
org.springframework.context.ApplicationListener             9个值
org.springframework.boot.env.EnvironmentPostProcessor       3个值
org.springframework.boot.diagnostics.FailureAnalyzer        13个值
org.springframework.boot.diagnostics.FailureAnalysisReporter  1个值

==================spring-boot-autoconfiguration================================

org.springframework.context.ApplicationContextInitializer  2个值
org.springframework.context.ApplicationListener            1个值
org.springframework.boot.autoconfigure.AutoConfigurationImportListener  1个值
org.springframework.boot.autoconfigure.AutoConfigurationImportFilter  3个值
org.springframework.boot.autoconfigure.EnableAutoConfiguration       118个值
org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider 5个值

3个配置文件合并后,

ApplicationContextInitializer  6个值

ApplicationListener               12个值

SpringApplicationRunListener  1个

总共13大类

打开断点看看结果是否匹配:刚好6个,完全匹配

 

12个监听器:刚好完全匹配

 获取运行时监听器,刚好1个,完全匹配

org.springframework.boot.SpringApplication#getRunListeners

 org.springframework.boot.SpringApplicationRunListeners#starting

发布一个容器启动事件

 这里有四个监听器在监听容器启动事件

 

http://www.lryc.cn/news/55822.html

相关文章:

  • 【网络安全】SQL注入--报错注入
  • APP隐私整改建议
  • MySQL数据模型 and 通用语法 and 分类
  • 一款识别域名是否使用cdn的工具cdnChecker
  • Ant Design Vue的汉化
  • spring cloud中实现接口广播请求到服务提供者
  • 电机PID参数调节笔记
  • 【深度学习】基于华为MindSpore的手写体图像识别实验
  • Linux:内核调试之内核魔术键sysrq
  • Python import导包快速入门
  • ChatGPT这么火,我们能怎么办?
  • HashMap底层原理
  • 卡顿优化小结
  • springboot前端ajax 04 关于后台传的时间和状态在前端的转换
  • 解决Windows微信和 PowerToys 的键盘管理器冲突
  • 组会时间的工作
  • linux udp bind 返回值-1分析
  • Hexo搭建博客
  • Lesson11:http协议
  • 计算机信息安全有哪些SCI期刊推荐? - 易智编译EaseEditing
  • CNVD-2023-12632 泛微e-cology9 sql注入 附poc
  • 赛宁网安合作伙伴大会成功举办,重磅发布SCBaaS服务!
  • R语言 4.2.2安装包下载及安装教程
  • 快速玩转 CNStack 2.0 流量防护
  • 你还在用原生 poi 处理 excel?太麻烦了来瞧瞧这个
  • No.027<软考>《(高项)备考大全》【第11章】项目风险管理
  • mit6.824 lab2c-数据持久化
  • leaflet使用L.geoJSON加载文件,参数filter的使用方法(127)
  • 23年5月高项学习笔记7—— 质量管理
  • 学编程需要哪些基础呢?一起来看看吧