專爲註解方式來處理的:spring
在AnnotationConfigUtils的registerAnnotationConfigProcessors方法注入以下幾類:
"org.springframework.context.annotation.internalConfigurationAnnotationProcessor" ->ConfigurationClassPostProcessor函數
"org.springframework.context.annotation.internalAutowiredAnnotationProcessor" -> AutowiredAnnotationBeanPostProcessorui
"org.springframework.context.annotation.internalRequiredAnnotationProcessor" -> RequiredAnnotationBeanPostProcessorblog
"org.springframework.context.annotation.internalCommonAnnotationProcessor" - > CommonAnnotationBeanPostProcessorit
"org.springframework.context.event.internalEventListenerProcessor" -> EventListenerMethodProcessorio
"org.springframework.context.event.internalEventListenerFactory" -> DefaultEventListenerFactoryevent
該方法在構建AnnotatedBeanDefinitionReader 和ClassPathBeanDefinitionScanner 執行scan方法時被調用List
springBoot:sso
AnnotationConfigApplicationContext 構造函數中初始化AnnotatedBeanDefinitionReader 和 ClassPathBeanDefinitionScanner構造函數
AnnotationConfigWebApplicationContext 在loadBeanDefinitions 方法中 初始化reader、scanner。 該方法在父類AbstractRefreshableApplicationContext調用refreshBeanFactory。源頭在AbstractApplicationContext的refresh()方法調用obtainFreshBeanFactory -> refreshBeanFactory.
SpringApplication.run ->SpringApplication. prepareContext -> SpringApplication.load ->BeanDefinitionLoader.load -> source instanceof Package 時 會調用ClassPathBeanDefinitionScanner.scan
XmlWebApplicationContext則是XmlBeanDefinitionReader.