Last active
July 23, 2024 06:40
-
-
Save caprica/635c92381c6e7f9dc3aa0d422f82c750 to your computer and use it in GitHub Desktop.
Spring Boot YAML configuration for lists (or arrays) of strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For a property in a Spring component like this: | |
# | |
# @Value("${property.name}") | |
# private List<String> values; | |
# | |
# Spring will fail to start up with a vague error saying something like | |
# "Could not resolve placeholder 'property.name' in value "${property.name}" | |
# even though the property definition is right there in the yaml file | |
# For example, ordinarily in a yaml file something like this: | |
property: | |
name: | |
- value1 | |
- value2 | |
# You must use different syntax (note the use of comma): | |
property: | |
name: > | |
value1, | |
value2 | |
# In fact, the > is not actually required, so this works (again note the comma): | |
property: | |
name: | |
value1, | |
value2 | |
# Or: | |
property: | |
name: value1, value2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment