spring boot
2020-05-20 18:34:54 16 举报
登录查看完整内容
学习图
作者其他创作
大纲/内容
1
这里开始真正的创建bean
4
发布ApplicationContextInitializedEvent事件
配置忽略某些beanspring.beaninfo.ignore
DisposableBean
finishRefresh()
创建class类的Beandifinition
2
LoggingApplicationListener
发布ApplicationEnvironmentPreparedEvent事件
org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext#selfInitialize
5
发布ContextRefreshedEvent事件
实例化ApplicationContextInitializerApplicationListener
registerBeanPostProcessors()
BeanPostProcessor
DelegatingApplicationListener
finishBeanFactoryInitialization(beanFactory)
CloudFoundryVcapEnvironmentPostProcessor
注册shutdown hook钩子
销毁beanFactory
发布ApplicationStartedEvent事件
使用SpringFactoriesLoader加载PropertySourceLoader得到
发布ApplicationStartingEvent事件
此时ConfigFileApplicationListener收到事件通知
发布ContextClosedEvent事件
创建SpringApplicationRunListener实例(也在spring.factories)
initApplicationEventMulticaster()
打印banner
开启后台线程,初始化:1、类型转换器 ConversionServiceInitializer2、校验器 ValidationInitializer3、消息转换器 MessageConverterInitializer4、序列化转换初始化器 JacksonInitializer5、编码初始化 CharsetInitializer
invokeBeanFactoryPostProcessors(beanFactory)
RandomValuePropertySource
EventPublishingRunListener
\"logback-test.groovy\
解析命令行参数
BeanFactoryPostProcessor
InitializingBean
FileEncodingApplicationListener
销毁bean,应用程序停止时会调用
注册一堆BeanPostProcessor,并按优先级进行排序
此时会new一个ClassPathBeanDefinitionScanner
调用实现了ApplicationRunnerCommandLineRunner接口的bean
beanFactory.preInstantiateSingletons()
createWebServer()
ApplicationListener
用于解析random.intrandom.longrandom.uuid等
会获取配置文件
三方云有关系
System.getEnv()
org.springframework.context.annotation.ConfigurationClassParser#retrieveBeanMethodMetadata
根据启动类解析出包名,并扫描classpath下的类
onRefresh()
prepareBeanFactory()
通过SpringFactoriesLoader创建异常处理器SpringBootExceptionReporter
replaces the systemEnvironment
获取系统属性、系统环境变量
触发
此时在构造方法里面创建了reader: ClassPathBeanDefinitionScannerscanner: ClassPathBeanDefinitionScanner
如果启动出错,则会把详细的异常堆栈打印出来
发布ApplicationReadyEvent事件
用于debug
ApplicationContextAware
筛选事件接收者
找到BeanDefinitionRegistryPostProcessor
发布ServletWebServerInitializedEvent事件
可在run时配置用用程序监听器
初始化webserver context
完成refresh清理缓存等
Spring 可扩展点跟通知
DebugAgentEnvironmentPostProcessor
LiquibaseServiceLocatorApplicationListener
通过SpringFactoriesLoader加载EnvironmentPostProcessor
starting
添加message source到beanFactory
只是加了个PropertySourceOrderingPostProcessor用于处理property
3
YamlPropertySourceLoader
org.springframework.core.io.support.SpringFactoriesLoader
refreshContext()
然后一层一层查找是否带有@Component注解的类
initMessageSource()
设置StandardBeanExpressionResolver用于解析spel表达式
prepareContext()
设置profiles到enviroment
AnsiOutputApplicationListener
从META-INF/spring.factories获取配置类
占位符解析器,用于解析${}里面的属性
实例化bean,此时可以修改bean相关属性等
找到之后再找方法是否有@Bean
根据之前配置的webApplicationType创建contextAnnotationConfigServletWebServerApplicationContext
可以对bean的定义(Definition)进行修改,此时bean还未实例化
PropertiesPropertySourceLoader
bean初始化完了
将之前的事件发布器添加到beanFactory
设置了个ApplicationConversionService
用于关闭context
ConfigFileApplicationListener
LoggingApplicationListener初始化日志系统,支持logback跟java log
MySQL
Spring boot
SystemEnvironmentPropertySourceEnvironmentPostProcessor
此时调用之前初始化的ApplicationContextInitializer
初始化子容器里面的其他bean
销毁bean
SpringApplicationJsonEnvironmentPostProcessor
通过web容器工厂创建web server
ClasspathLoggingApplicationListener
可获取上下文context
System.getProperties()
PropertySourcesPlaceholdersResolver用于替换${}
startWebServer()
BackgroundPreinitializer
0 条评论
回复 删除
下一页