I have a list of values in one property in application.properties
file:
my-property=abc,def,ghi
And I load it in my @ConfigurationProperties
class:
@Configuration
@ConfigurationProperties
public class MyProperties {
private List<String> myProperty;
}
But I don't know how to change delimiter (from comma to semicolon or other separator):
my-property=abc;def;ghi
I know I can write workaround, but I don't want to use them because:
- @Value for property, but it requires manually writing property name for each fields (loss of
@ConfigurationProperties
advantages).
@Value("#{'${my-property}'.split(';')}")
private List<String> myProperty;
- Many properties with index, but it requires manually indexing and it's arduous when there are a lot of them and you have to change the order:
my-property[0]=abc
my-property[1]=def
my-property[2]=ghi
- Writing getter with
split
, but I have to write getter for all properties manually:
private String myProperties;
public List<String> getMyProperty() {
return Arrays.asList(myProperties.split(";"));
}