加载XML配置文件的BeanFactory的使用演示
public static void main(String[] args) { DefaultListableBeanFactory beanRegistry=new DefaultListableBeanFactory(); BeanFactory container=(BeanFactory)bindViaXMLFile(beanRegistry); FXNewsProvider newsProvider=(FXNewsProvider)container.getBean("djNewsProvider"); newsProvider.getAndPersistNews(); } public static BeanFactory bindViaXMLFile(BeanDefinitionRegistry registry) { XmlBeanDefinitionReader reader=new XmlBeanDefinitionReader(registry); reader.loadBeanDefinitions("classpath:../news-config.xml"); return (BeanFactory)registry; //或者直接 //return new XmlBeanFactory(new ClassPathResource("../news-config.xml")); }