public interface BeanFactoryPostProcessor {
/**
* Modify the application context's internal bean factory after its standard
* initialization. All bean definitions will have been loaded, but no beans
* will have been instantiated yet. This allows for overriding or adding
* properties even to eager-initializing beans.
* @param beanFactory the bean factory used by the application context
* @throws org.springframework.beans.BeansException in case of errors
*/
void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
【Spring】BeanFactoryPostProcessor 向容器添加自定义bean
最新推荐文章于 2023-10-24 12:02:45 发布
本文介绍了Spring框架中BeanFactoryPostProcessor接口的使用,该接口的postProcessBeanFactory方法允许我们在容器中添加自定义BeanDefinition。然而,ConfigurableListableBeanFactory本身并不直接提供注册BeanDefinition的接口,需要通过其子类DefaultListableBeanFactory的registerBeanDefinition方法来实现。需要注意的是,不应自行创建DefaultListableBeanFactory实例,否则将无法与现有容器关联。
摘要由CSDN通过智能技术生成