【发布时间】:2015-04-14 05:36:56
【问题描述】:
我正在尝试将 .properties 文件中的地图加载到 HashMap
属性文件有以下内容:
try.map= one=1,\
two=2
代码:
@org.springframework.beans.factory.annotation.Value("${try.map}")
HashMap<String, String> tryMap;
将属性加载到地图会导致:
java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [java.util.HashMap]: no matching editors or conversion strategy found
任何想法如何为此创建映射策略?
【问题讨论】:
-
您有自己的转换器并将其添加到coverationService。