一、BeanFactoryPostProcessor
BeanFactory的后置处理器:在BeanFactory标准初始化之后调用,来定制和修改BeanFactory的内容;所有的bean定义已经保存加载到beanFactory,但是bean的实例还未创建。
1,使用源码:MyBeanFactoryPostProcess
@Component public class Demo01_MyBeanFactoryPostProcess implements BeanFactoryPostProcessor { @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { System.out.println("MyBeanFactoryPostProcessor...postProcessBeanFactory..."); int definitionCount = beanFactory.getBeanDefinitionCount(); String[] definitionNames = beanFactory.getBeanDefinitionNames(); System.out.println("beanFactory中一共有 " + definitionCount + " 个bean,分别为: " + Arrays.toString(definitionNames)); } }