Skip to content

Instantly share code, notes, and snippets.

@caprica
Last active September 7, 2023 20:46
Show Gist options
  • Save caprica/635c92381c6e7f9dc3aa0d422f82c750 to your computer and use it in GitHub Desktop.
Save caprica/635c92381c6e7f9dc3aa0d422f82c750 to your computer and use it in GitHub Desktop.
Spring Boot YAML configuration for lists (or arrays) of strings
# 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