杭州比较好的网站建设公司,南宁网络推广有几家,制作WordPress主题自适应,滁州网站开发公司电话1.寻找spring.factories配置文件对应的监听器#xff0c;主要要写监听器的全路径名#xff0c;不然反射会报错 SpringBoot底层是如何读取META-INF/spring.factories的配置的#xff1f;
1.遍历所有jar下的META-INF/spring.factories配置文件
2.读取配置文件下的所有属性主要要写监听器的全路径名不然反射会报错 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 发布一个容器启动事件 这里有四个监听器在监听容器启动事件