Spring .properties file: get element as an Array

后端 未结 5 1747
灰色年华
灰色年华 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:33

    And incase you a different delimiter other than comma, you can use that as well.

    @Value("#{'${my.config.values}'.split(',')}")
    private String[] myValues;   // could also be a List
    

    and

    in your application properties you could have

    my.config.values=value1, value2, value3
    

提交回复
热议问题