spring复习:(31)手动给DefaultListableBeanFactory注册BeanPostProcessor

不像ApplicationContext那样能自动注册BeanPostProcessor. BeanFactory必须要手动注册

        Resource resource = new ClassPathResource("beans13.xml");
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();


        BeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(factory);
        beanDefinitionReader.loadBeanDefinitions(resource);

        BeanPostProcessor beanPostProcessor = (BeanPostProcessor)factory.getBean("fgh");
        factory.addBeanPostProcessor(beanPostProcessor);

你可能感兴趣的:(Spring,spring,java,数据库)