栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

03 Spring 源码总结 - ConfigurationClassPostProcessor

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

03 Spring 源码总结 - ConfigurationClassPostProcessor

文章目录
    • ConfigurationClassPostProcessor
      • 类图
      • 概述
      • postProcessBeanDefinitionRegistry()
      • postProcessBeanFactory()
      • 相关文章

ConfigurationClassPostProcessor 类图

概述
  • 该类实现了 BeanDefinitionRegistryPostProcessor 接口,所以会重写 postProcessBeanDefinitionRegistry() 方法和 postProcessBeanFactory() 方法。

  • 在 postProcessBeanDefinitionRegistry() 方法中解析了加了@Configuration注解的类,同时解析出 @ComponentScan 和 @ComponentScans 扫描出的Bean,也会解析出加了 @Bean 注解的方法所注册的Bean,以及通过 @Import 注解注册的Bean和 @ImportResource 注解导入的配置文件中配置的Bean。在 postProcessBeanDefinitionRegistry() 方法中,通过源码分析了两个十分重要的方法:ConfigurationClassParser.parse()和this.reader.loadBeanDefinitions()

  • 在**postProcessBeanFactory()**方法中,会利用CGLIB对加了@Configuration注解的类创建动态代理,进行增强。最后还会向spring容器中添加一个Bean后置处理器:ImportAwareBeanPostProcessor

postProcessBeanDefinitionRegistry()

postProcessBeanFactory()

相关文章

ConfigurationClassPostProcessor —— Spring中最!最!最!重要的后置处理器!没有之一!!!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/973637.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号