Spring源码invokeBeanFactoryPostProcessors方法说明(二)

Spring源码invokeBeanFactoryPostProcessors方法说明(二)

一、开始
1、寻找配置类(org.springframework.context.annotation.ConfigurationClassPostProcessor#processConfigBeanDefinitions)
在这里插入图片描述
2、checkConfigurationClassCandidate中有这样一段代码
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
看完这段代码是不是突然get到什么东西了,是不是对于寻找配置类的方法有所了解了。

3、重点(org.springframework.context.annotation.ConfigurationClassParser#parse)
在这里插入图片描述
在这里插入图片描述
4、doProcessConfigurationClass分析
在这里插入图片描述
在这里插入图片描述
5、doProcessConfigurationClass–>@PropertySource注解分析
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
6、doProcessConfigurationClass–>@ComponentScan注解分析(重点)

在这里插入图片描述
parse:创建ClassPathBeanDefinitionScanner,把componentScan转换成ClassPathBeanDefinitionScanner
在这里插入图片描述
在这里插入图片描述
下面主要分析doScan里的这两个方法
在这里插入图片描述
findCandidateComponents方法分析
在这里插入图片描述
在这里插入图片描述
findCandidateComponents–>isCandidateComponent
在这里插入图片描述
findCandidateComponents–>registerBeanDefinition,一目了然,注册beanDefinition,注册别名
在这里插入图片描述
二、结束
本章主要分析了 @PropertySource和@ComponentScan源码。下一章将分析@Import源码。

猜你喜欢

转载自blog.csdn.net/mlplds/article/details/102807610
今日推荐