在将yaml文件加载到对象时遇到问题。这是我的yaml文件的结构:
somePrefix
variableName:
SOME_ENUM_VALUE:
- TEST1
- TEST2
- TESTN
下面是我的代码:
@Configuration
@ConfigurationProperties(prefix = "somePrefix")
data class SomeFeatureConfiguration(
var variableName: Map<SOME_ENUM, List<String>>? = null
)
这行不通。我正在尝试使用Java进行完全相同的操作,并且可以正常工作。我花了很多时间试图弄清楚发生了什么,但我怀疑这是科特林的问题。有没有人尝试过类似的东西?
我在启动应用程序时遇到以下异常:
Caused by: java.lang.NullPointerException: null
at org.springframework.boot.bind.RelaxedDataBinder.extendCollectionIfNecessary(RelaxedDataBinder.java:340)
at org.springframework.boot.bind.RelaxedDataBinder.initializePath(RelaxedDataBinder.java:290)
at org.springframework.boot.bind.RelaxedDataBinder.initializePath(RelaxedDataBinder.java:307)
at org.springframework.boot.bind.RelaxedDataBinder.normalizePath(RelaxedDataBinder.java:259)
at org.springframework.boot.bind.RelaxedDataBinder.modifyProperty(RelaxedDataBinder.java:240)
at org.springframework.boot.bind.RelaxedDataBinder.modifyProperties(RelaxedDataBinder.java:155)
at org.springframework.boot.bind.RelaxedDataBinder.doBind(RelaxedDataBinder.java:128)
at org.springframework.validation.DataBinder.bind(DataBinder.java:740)