Spring .properties file: get element as an Array

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

    If you define your array in properties file like:

    base.module.elementToSearch=1,2,3,4,5,6
    

    You can load such array in your Java class like this:

      @Value("${base.module.elementToSearch}")
      private String[] elementToSearch;
    

提交回复
热议问题