加载Properties配置的BeanFactory的使用演示

 1 public static void main(String[] args)

 2 {

 3   DefaultListableBeanFactory  beanRegistry=new DefaultListableBeanFactory();

 4   BeanFactory container=(BeanFactory)bindViaPropertiesFile(beanRegistry);

 5 

 6   FXNewsProvider newsProvider=(FXNewsProvider)container.getBean("djNewsProvider");  

 7   newsProvider.getAndPersistNews();

 8 }

 9 

10 public static BeanFactory bindViaPropertiesFile(BeanDefinitionRegistry registry)

11 {

12   PropertiesBeanDefinitionReader reader= new PropertiesBeanDefinitionReader(registry);

13   reader.loadBeanDefinitions("classpath:http://www.cnblogs.com/binding-config.properties");

14   

15   return (BeanFactory)registry;

16 }

 

你可能感兴趣的:(beanfactory)