srping 待完善
2020-04-25 15:57:42 0 举报
AI智能生成
spring boot 整理
作者其他创作
大纲/内容
SpringBootApplication
SpringApplication#run
获取监听器getRunListeners
getSpringFactoriesInstances
loadFactoryNames
缓存中获取type为SpringApplicationRunListener 类名
创建返回 org.springframework.boot.context.event.EventPublishingRunListener
listeners.starting
EventPublishingRunListener
org.springframework.context.event.SimpleApplicationEventMulticaster#multicastEvent(org.springframework.context.ApplicationEvent)
getApplicationListeners
ApplicationStartingEvent 和SpringBootApplication 作为Key
缓存维护 retrieveApplicationListeners
默认加载4个
invokeListener
执行 onApplicationEvent
配置文件加载prepareEnvironment
触发监听器environmentPrepared
监听器
ConfigFileApplicationListener
默认走 org.springframework.boot.context.config.ConfigFileApplicationListener#onApplicationEnvironmentPreparedEvent
找出EnvironmentPostProcessor 子类
SystemEnvironmentPropertySourceEnvironmentPostProcessor
名称 systemEnvironment
修改结构
SpringApplicationJsonEnvironmentPostProcessor
默认找找不到
CloudFoundryVcapEnvironmentPostProcessor
默认没有包含 VCAP_APPLICATION 和 VCAP_SERVICES 的配置
添加random 配置
添加 application配置 org.springframework.boot.context.config.ConfigFileApplicationListener.Loader
initializeProfiles
获取spring.profiles.active 和 spring.profiles.include配置
addLoadedPropertySources 配置读完后添加到 Source
DebugAgentEnvironmentPostProcessor
https://github.com/reactor/reactor-tools
默认不开启
AnsiOutputApplicationListener
LoggingApplicationListener
BackgroundPreinitializer
ClasspathLoggingApplicationListener
DelegatingApplicationListener
FileEncodingApplicationListener
创建上下文createApplicationContext
准备上下文prepareContext
刷新上下文refreshContext
AbstractApplicationContext#refresh
准备刷新prepareRefresh
刷新内部bean工厂 obtainFreshBeanFactory
注册拦截bean创建的bean处理器。registerBeanPostProcessors
实例化单例bean finishBeanFactoryInitialization
默认工厂 DefaultListableBeanFactory
实例化单例bean preInstantiateSingletons
获取bean AbstractBeanFactory#doGetBean
创建bean createBean
AbstractAutowireCapableBeanFactory#doCreateBean
创建bean createBeanInstance
判断构造方法注解 determineConstructorsFromBeanPostProcessors
applyMergedBeanDefinitionPostProcessors
注入查找 AutowiredAnnotationBeanPostProcessor#postProcessMergedBeanDefinition
检测需要注入属性ReflectionUtils.doWithLocalFields
检测需要注入方法 ReflectionUtils.doWithLocalMethods
注入 populateBean
AutowiredAnnotationBeanPostProcessor#postProcessProperties
收藏
收藏
0 条评论
下一页