André Martins
10/16/2024, 9:25 AM@Configuration
@ConfigurationProperties(prefix = "my-config")
data class MyConfig(
var blacklist: List<BlackListEntry> = emptyList(),
)
data class BlackListEntry(
val name: String,
val values: List<String> = emptyList(),
)
And I'm using spring.config.import
to import an additional application.yaml in my environment. The thing is I get java.lang.IllegalStateException: No setter found for property: blacklist
When I change the blacklist to be a MutableList it works, does spring first instantiate MyConfig for the base application.yaml and then try to call the setters with the additional imports? Shouldn't it merge the yamls first and only call the constructor once? Any ideias how can I keep the list as immutable?
Im using spring-boot 3.2 btw
Thanks in advance ✌️David Kubecka
10/16/2024, 10:43 AMval
everywhere. Did you try that?André Martins
10/16/2024, 1:26 PMDavid Kubecka
10/16/2024, 1:29 PMval list: List<...> = ...
in my Spring app with imported config and it works for me. So perhaps the problem might be somewhere else?André Martins
10/16/2024, 1:46 PMAndré Martins
10/16/2024, 1:46 PMspring.config.import
?David Kubecka
10/16/2024, 2:12 PMspring.config.import
David Kubecka
10/16/2024, 2:12 PMAndré Martins
10/16/2024, 2:16 PMAndré Martins
10/16/2024, 2:17 PMAndré Martins
10/16/2024, 2:17 PMDavid Kubecka
10/16/2024, 2:41 PMvar blacklist =
André Martins
10/16/2024, 2:46 PMAndré Martins
10/16/2024, 3:46 PMAndré Martins
10/16/2024, 3:46 PM= emptyList()
it worksPihentagy
10/22/2024, 6:33 AMmutableListOf()
defaultJilles Soeters
10/22/2024, 5:04 PMPihentagy
10/22/2024, 5:22 PM