spring源码解析之ConfigurationClassPostProcessor对@Configuration注解的处理

1.简介

之前讨论过,spring框架在读取配置类Bean定义时,会预先注册一系列BeanDefinitionRegistryPostProcessor、BeanPostProcessor

用来处理@Configuration、@Autowired等注解

其中ConfigurationClassPostProcessor就是用来处理@Configuration注解,读取配置类,注册配置的Bean定义。

2.继承结构

  1. 实现了BeanDefinitionRegistryPostProcessor接口,用于发现所有的@Configuration配置类,然后注册其中的Bean定义
  2. 实现了BeanFactoryPostProcessor接口,用于增强配置类
  3. 实现了PriorityOrdered接口,代表此后处理器是优先排序的
  4. 其他接口不是很重要

3.后处理Bean定义注册

    /**
	 * 处理{@link Configuration}注解类,从注册表中的配置类派生更多的bean定义。
	 */
	@Override
	public v

猜你喜欢

转载自blog.csdn.net/qq_27868061/article/details/109078716