Reading a List from properties file and load with spring annotation @Value

前端 未结 16 1521
陌清茗
陌清茗 2020-11-22 14:01

I want to have a list of values in a .properties file, ie:

my.list.of.strings=ABC,CDE,EFG

And to load it in my class directly, ie:

16条回答
  •  旧巷少年郎
    2020-11-22 14:37

    In my case of a list of integers works this:

    @Value("#{${my.list.of.integers}}")
    private List listOfIntegers;
    

    Property file:

    my.list.of.integers={100,200,300,400,999}
    

提交回复
热议问题