Reputation: 1980
I am configuring my Spring Boot application with an application.yml file:
foo:
bar: foobar
foolist:
- bar: foobar1
baz: foobaz1
- bar: foobar1
baz: foobaz1
I can easily set the foo.bar value with an environment variable, e.g.
export FOO_BAR=value
How can I set values of the foolist entrie? FOOLIST[0]_BAR
is not a valid identifier and FOOLIST_0_BAR
does not work.
Upvotes: 8
Views: 5953
Reputation: 15214
It's possible to provide arbitrary JSON object in the SPRING_APPLICATION_JSON
environment variable:
export SPRING_APPLICATION_JSON='{"foolist":[{"bar": "foobar1", "baz: foobaz1"}, {"bar": "foobar2", "baz: foobaz2"}]}'
Documentation is here: https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/boot-features-external-config.html
Upvotes: 6