Hi, so I think there is an unexpected behavior around the configuration parsing
See the following application.yml
some:
values-string: "this is a string"
values-string-list: "this, is, a, list"
And my configuration class
@Configuration
@Getter
public class SomeConfig {
@Value("${some.values-string}")
private List<String> valuesString = new ArrayList<>();
@Value("${some.values-string-list}")
private List<String> valuesStringList = new ArrayList<>();
}
Then we will have the following in SomeConfig
valuesString == ["this is a string"]
valuesStringList == ["this", "is", "a", "list"]
I would have expected valuesStringList to be ["this, is, a, string"]
Comment From: wilkinsona
This is to be expected and is described in table 3 of this section of the documentation where it says that a list in a YAML file can be declared using "standard YAML list syntax or comma-separated values". When you declare a list as a comma-separated value, it's automatically split on those commas. If you want it to be a single value containing commas, declare it as a list with a single entry:
some:
values-string:
- "this is a string"
values-string-list
- "this, is, a, list"
The same applies to properties files although the syntax is different:
some.values-string[0]=this is a string
some.values-string-list[0]=this, is, a, list
You may also need to use @ConfigurationProperties rather than @Value to consume the values.
Comment From: AminArria
Thanks for quick reply, missed that comment in the docs