Springboot自动配置简单版
2021-06-24 18:48:04 2 举报
自动装配原理
作者其他创作
大纲/内容
new SpringApplication
1:class级别的初步筛选
handler.processGroupImports()
。。。。。
grouping.getImports()
......
foreach处理processImports
deferredImports.forEach(handler::register)
在处理import这注册的AutoConfigurationImportSelector
3:对方法上的Condition进行筛选
invokeBeanFactoryPostProcessors
按照@AutoConfigureBefore@AutoConfigureAfter@AutoConfigureOrder排序
filter(configurations)
推断是不是个Servlet
getAutoConfigurationEntry
ConfigurationClassParser.parse
ConfigurationClassParser.processImports
run
reader.loadBeanDefinitions(configClasses);
ConfigurationClassPostProcessor.processConfigBeanDefinitions
shouldSkip
spring.factories中所有EnableAutoConfiguration
foreach处理condition.matches
sortAutoConfigurations
conditionEvaluator.shouldSkip
doProcessConfigurationClass
deferredImportSelectorHandler.process()
context.refresh
2:对内部类进行筛选
如果selector instanceof DeferredImportSelector
Exclusions
processConfigurationClass
group.process
parse
group.selectImports()
createApplicationContext
使用内置处理器DeferredImportSelectorGroupingHandler按照Group分组selector
getConfigurationClassFilter()
prepareEnvironments
spring.factories中所有AutoConfigurationImportFilter
loadBeanDefinitionsForBeanMethod(beanMethod);
0 条评论
回复 删除
下一页