日期:2014-05-20  浏览次数:20758 次

spring 3.1.0源码中说The type XmlBeanFactory is deprecated,那用什么替代
源码中有一段说:
@deprecated
as of Spring 3.1 in favor of DefaultListableBeanFactory and XmlBeanDefinitionReader

可是具体该怎么用DefaultListableBeanFactory 和XmlBeanDefinitionReader呢?

------解决方案--------------------
Resource res = new ClassPathResource("bean.xml");
DefaultListableBeanFactory factory= new DefaultListableBeanFactory ();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
reader.loadBeanDefinitions(resource)