Access properties file programmatically with Spring?

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

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



        
15条回答
  •  广开言路
    2020-11-27 09:54

    I have done this and it has worked.

    Properties props = PropertiesLoaderUtils.loadAllProperties("my.properties");
    PropertyPlaceholderConfigurer props2 = new PropertyPlaceholderConfigurer();
    props2.setProperties(props);
    

    That should work.

提交回复
热议问题