1. Introduction
In this tutorial, You'll learn about BeanDefinitionRegistryPostProcessor interface in Spring and Spring Boot.
Spring Framework API - BeanDefinitionRegistryPostProcessor is used to register the bean dynamically with application context at runtime. This is most useful in the realtime when working with client libraries those are changed frequently. By using this bean, you can reduce the deployments of the application but you should use this with care. Otherwise, It will override the existing bean configuration.
Spring BeanDefinitionRegistryPostProcessor interface has one abstract method "void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException".
This is mainly useful if you have any third-party libraries which are not spring beans. So, these beans can be registered dynamically at runtime based on your need.
BeanDefinitionRegistryPostProcessor is also one of the interfaces to register the beans at runtime without using @Bean or @Component annotations in the program.
From API:
Extension to the standard BeanFactoryPostProcessor SPI, allowing for the registration of further bean definitions before regular BeanFactoryPostProcessor detection kicks in. In particular, BeanDefinitionRegistryPostProcessor may register further bean definitions which in turn define BeanFactoryPostProcessor instances.
So, Any classes that implement the BeanDefinitionRegistryPostProcessor interface will be executed before the start BeanFactoryPostProcessor registration.
This is mainly useful if you have any third-party libraries which are not spring beans. So, these beans can be registered dynamically at runtime based on your need.
BeanDefinitionRegistryPostProcessor is also one of the interfaces to register the beans at runtime without using @Bean or @Component annotations in the program.
From API:
Extension to the standard BeanFactoryPostProcessor SPI, allowing for the registration of further bean definitions before regular BeanFactoryPostProcessor detection kicks in. In particular, BeanDefinitionRegistryPostProcessor may register further bean definitions which in turn define BeanFactoryPostProcessor instances.