【发布时间】:2020-07-14 03:08:24
【问题描述】:
我有一个收藏
@Component
@ConfigurationProperties(prefix="com.ptsb.refData")
public class RefDataConfigMap {
private Map<String,Map<String,List<RefDataResponse>>> entries;
public Map<String, Map<String, List<RefDataResponse>>> getEntries() {
return entries;
}
public void setEntries(Map<String, Map<String, List<RefDataResponse>>> entries) {
this.entries = entries;
}
参考数据响应:
public class RefDataResponse {
@JsonProperty("sourceSystem")
private String refKeyTgtSystem = null;
@JsonProperty("sourceSystemValue")
private String refKeyTgtSystemValue = null;
public String getRefKeyTgtSystem() {
return refKeyTgtSystem;
}
public void setRefKeyTgtSystem(String refKeyTgtSystem) {
this.refKeyTgtSystem = refKeyTgtSystem;
}
public String getRefKeyTgtSystemValue() {
return refKeyTgtSystemValue;
}
public void setRefKeyTgtSystemValue(String refKeyTgtSystemValue) {
this.refKeyTgtSystemValue = refKeyTgtSystemValue;
}
}
我正在 application.yml 中初始化,如下所示
com:
ptsb:
refData:
entries:
GENDER:
Male:
- refKeyTgtSystem:Siebel
refKeyTgtSystemValue:M
我在尝试执行应用程序时遇到错误。
未能将类型“java.lang.String”的属性值转换为属性“条目[GENDER][Male][0]”所需的类型“com.ptsb.ref.models.RefDataResponse”;嵌套异常是 java.lang.IllegalStateException:无法将类型 'java.lang.String' 的值转换为属性 'entries[GENDER][Male][0]' 所需的类型 'com.ptsb.ref.models.RefDataResponse':未找到匹配的编辑器或转换策略
如何在应用 yml 中初始化这个?
【问题讨论】:
标签: java spring-boot collections yaml