在Yaml中,我具有以下属性:
threadPools:
poollA:
size: 10
maxSize: 20
poolB:
size: 20
如何编写@ConfigurationProperties类以将此配置映射为具有池配置的Map?
如果再有一个级别,这很容易:
threadPools:
configs:
poollA:
size: 10
maxSize: 20
poolB:
size: 20
和java(实际上是Kotlin)类:
@ConfigurationProperties("threadPools")
internal class ThreadPoolsProperties {
val configs: Map<String, ThreadPoolConfig> = mutableMapOf()
internal class ThreadPoolConfig {
var size: Int = 10
var maxSize: Int = 10
}
}
但是第一个例子呢?