-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Open
Labels
status: waiting-for-feedbackWe need additional information before we can continueWe need additional information before we can continuestatus: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged
Description
I have list of objects in my properties and I want populate them by env variables. Spring boot version = 3.5.3
.
Example of my properties structure:
my:
tests:
- a: foo
b: bar
- a: hello
b: world
My kotlin code:
data class Test(val a: String, val b: String)
@ConfigurationProperties(prefix = "my")
data class MyProperties(val tests: List<Test>)
and I want fill them with environment variables:
MY_TESTS_0_A=foo
MY_TESTS_0_B=bar
MY_TESTS_1_A=hello
MY_TESTS_1_B=world
But the tests
is always empty.
I tried multiple combination with list of Strings or object with single field. Both works.
@ConfigurationProperties(prefix = "my")
data class MyProperties(val tests: List<String>)
MY_TESTS_0=foo
MY_TESTS_1=bar
data class Test(val a: String, val b: String)
@ConfigurationProperties(prefix = "my")
data class MyProperties(val tests: List<String>)
MY_TESTS_0=foo
MY_TESTS_1=bar
The mapping somehow works, but not for objects with multiple fields.
Workaround is to use env SPRING_APPLICATION_JSON
and pass values as JSON.
Metadata
Metadata
Assignees
Labels
status: waiting-for-feedbackWe need additional information before we can continueWe need additional information before we can continuestatus: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged