BeanDefinitionRegistryPostProcessor作用及加载顺序 原创 2022-02-15 11:53:48.0 阅读(1748)次 BeanDefinitionRegistryPostProcessor接口常用于给接口动态添加代理类。这个接口中有一个方法如下: ```java public interface BeanDefinitionRegistryPostProcessor extends BeanFactoryPostProcessor { /** * Modify the application context's internal bean definition registry after its * standard initialization. All regular bean definitions will have been loaded, * but no beans will have been instantiated yet. This allows for adding further * bean definitions before the next post-processing phase kicks in. * @param registry the bean definition registry used by the application context * @throws org.springframework.beans.BeansException in case of errors */ void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException; } ``` postProcessBeanDefinitionRegistry方法的说明解释翻译如下: ``` 在标准初始化之后修改应用程序上下文的内部bean定义注册表。所有常规bean定义都已加载,但尚未实例化任何bean。这允许在下一个后处理阶段开始之前添加更多bean定义。 ``` 我再引用一下csdn上的一张图片,展示了BeanDefinitionRegistryPostProcessor处在spring启动加载流程的哪个阶段,如下:  也就是说这个方法能做的就是增加或修改类bean的定义而已,所有类还没有实例化,所以在这个接口的实现中的写一些代码时有很多限制,比如不能正常的注入我们自己定义的类实例,如果强制注入,那么这些类将不能正常的按spring流程来实例化,不能正常使用。这也解释了我上一篇文章中提到的取不到配置类中的配置问题。具体问题可以看这里:[http://www.classinstance.cn/detail/178.html](http://www.classinstance.cn/detail/178.html "http://www.classinstance.cn/detail/178.html") spring 上一篇:BeanDefinitionRegistryPostProcessor的实现类中注入不了类 下一篇:postgresql jdbc driver驱动连接属性列表
相关文章 BeanDefinitionRegistryPostProcessor的实现类中注入不了类(1973) Spring boot跨域配置(2028) spring boot多module项目导入Eclipse(2380) 获取eureka的注册服务的实例列表(1857) spring boot项目默认日志配置(1110) spring事务管理与查询是否需要事务以及可重复读的问题(3594) the dependencies of some of the beans in the application context form a cycle(16570) Spring boot项目引入jar包时启动报错:java.lang.StackOverflowError(4686) spring boot项目时间字段少8小时问题(1833) 如何实现生产环境关闭swagger,只有开发环境中开启swagger(7100) 推荐文章 使用spring4实现websocket连接(1) Parameter index out of range (1 > number of parameters, which is 0(7) spring cloud+feign+mybatis中使用seata0.9实现分布式事务(7) spring cloud gateway报错Only one connection receive subscriber allowed(82) spring cloud中Feign调用诡异报错MethodNotAllowed: status 405 reading(116) elasticsearch7.1保存时报错: Validation Failed: 1: type is missing;(7) 聊聊数据保存到MySQL后数据乱码的问题(1) jquery对象与dom对象互转(1) linux使用epel源yum安装iftop、nload、nginx等(2) linux下nginx安装其他模块(1) 热门文章 java stream去重的几种方式(40819) the dependencies of some of the beans in the application context form a cycle(16324) 解决mybatis打印查询结果集造成太多日志的问题(9839) java enum枚举转list和Map(9722) java stream List转Map与List转List与Map转List以及List转Map(8468) ServletRequest转HttpServletRequest设置header之后取不到header的问题(8434) java中BufferedImage转成 base64字符串(8098) 切分List集合为多个List集合(7385) maven修改jar包版本不生效解决办法(6990) bootstrap.yml配置报错:Could not resolve placeholder 'xx' in value (6949) 标签列表 java java java java java java java基础 微服务 异常处理 mysql clickhouse clickhouse clickhouse clickhouse clickhouse spring cloud spring boot linux elasticsearch feign jdbc spring js docker postgresql solr seata nginx maven gateway hsqldb 数据库 架构 大数据分析 分布式事务 redis canal dubbo hadoop 消息队列 win10 websocket springmvc git html select2 mybatis jenkins rocketmq quartz activemq 数据库集群 ajax bat 电脑 笔记 eclipse 设计模式 阿里云 github freemarker jvm jquery javamail redission redission对象 hystrix http hibernate springmail svn ubuntu ueditor xheditor zookeeper 分布式 小程序 开发工具 gitlab