Spring .properties file: get element as an Array

后端 未结 5 1770
灰色年华
灰色年华 2020-12-02 15:21

I\'m loading properties attributes from a .properties file using Spring as follows:

file: elements.properties
base.module.elementToSearch=1
base         


        
5条回答
  •  囚心锁ツ
    2020-12-02 15:50

    Here is an example of how you can do it in Spring 4.0+

    application.properties content:

    some.key=yes,no,cancel
    

    Java Code:

    @Autowire
    private Environment env;
    
    ...
    
    String[] springRocks = env.getProperty("some.key", String[].class);
    

提交回复
热议问题