Java的註解機制——Spring自動裝配的實現原理
https://www.cnblogs.com/adolfmc/p/4383087.html
註解掃描類,掃描的過程中會處理註解
org.springframework.context.annotation.ComponentScanAnnotationParser#parse
org.springframework.context.annotation.ClassPathBeanDefinitionScanner#doScan
以下處理Process any @Import annotations
org.springframework.context.annotation.ConfigurationClassParser#processImports
如下方法處理 @Component @PropertySources @ComponentScans @ComponentScan @ImportResource 註解
org.springframework.context.annotation.ConfigurationClassParser#doProcessConfigurationClass
如下方法處理 @Lazy @Primary @DependsOn @Role @Description 註解
org.springframework.context.annotation.AnnotationConfigUtils#processCommonDefinitionAnnotations(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition, org.springframework.core.type.AnnotatedTypeMetadata)
獲取帶有@Autowired和@Value註解的屬性對象
按以下代碼流程進行註解注入
- org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#applyMergedBeanDefinitionPostProcessors
- org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor#postProcessMergedBeanDefinition
- org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor#processInjection
- org.springframework.beans.factory.annotation.InjectionMetadata#inject
- org.springframework.beans.factory.annotation.InjectionMetadata.InjectedElement#inject
- 獲取待注入的對象org.springframework.beans.factory.annotation.InjectionMetadata.InjectedElement#getResourceToInject
- 獲取待注入的對象org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.ResourceElement#getResourceToInject
- 獲取對象資源org.springframework.context.annotation.CommonAnnotationBeanPostProcessor#getResource
- 獲取帶有@Autowired和@Value註解的屬性對象org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor#findAutowiredAnnotation
獲取帶有@Component和@Value註解的屬性對象
按以下代碼流程進行註解注入
Spring系列之IOC(2)——bean獲取方法getBean解析
https://www.jianshu.com/p/a04421bad1aa
Spring AbstractApplicationContext抽象類的refresh()方法–筆記
https://www.cnblogs.com/GooPolaris/p/8184429.html
Spring Bean生命週期-finishBeanFactoryInitialization(九)
http://www.imooc.com/article/details/id/253222
spring beans源碼解讀之–總結篇
https://www.cnblogs.com/davidwang456/p/4213652.html