test.yml (location: resources/properties/)
edit:
field1: test
field2: test
field3: test
field4: test
PropertyConfig.kt
@Configuration
@PropertySource("classpath:properties/test.yml")
class PropertyConfig {
@Bean
@ConfigurationProperties(prefix = "edit")
fun testProperty() = mutableMapOf<String, String>()
}
@Service
class EditService(
private val testProperty: Map<String, String>
) {
fun print() {
println(testProperty) // empty
}
}
I want to receive the values below edit as a map.
I tried options for @ConfigurationProperties with prefix and value, but it doesn't work.
If I use properties file, it works well, but not yml file.
What am I missing? Thanks.
kotlinVersion = '1.6'; springBootVersion = '2.6.1'