Access properties file programmatically with Spring?

前端 未结 15 1685
说谎
说谎 2020-11-27 09:37

We use the code below to inject Spring beans with properties from a properties file.



        
15条回答
  •  悲&欢浪女
    2020-11-27 10:03

    Here is another sample .

    XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource("beans.xml"));
    PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
    cfg.setLocation(new FileSystemResource("jdbc.properties"));
    cfg.postProcessBeanFactory(factory);
    

提交回复
热议问题