Reputation: 1901
I want this property mapped on application.properties
my.list=a;b;c
converted to a List (or eventually a String[]); there are 2 requirements;
I tried with:
@Value("#{T(java.util.Arrays).asList('${my.list:}'.split(';'))}")
but it doesn't work as expected, as passing multiple values convert the list with a single element "a,b,c".
PS I already know there is a very similare SO question, however the solution was not tested with separator different from ','.
Upvotes: 1
Views: 1359
Reputation: 7656
Just use
@Value("#{'${my.list:}'.split(';')}#{T(java.util.Collections).emptyList()}")
List<String> listValue;
Upvotes: 3