从配置服务器,我想将该属性作为地图注入到我的服务中。我可以使用 @ConfigurationProperties 注释来做到这一点;但是使用从配置服务器读取的@Value(连同@RefreshScope);但是抛出异常:无法将类型 [java.lang.String] 的值转换为所需类型 [java.util.Map]:找不到匹配的编辑器或转换策略
application.yml:(in config server)
user:
test:
key1:
val1,val2
key2:
val1,val2
@Service
//@ConfigurationProperties(prefix="user")
@RefreshScope
public class Example {
@Value("${user}")
Map<String, List<String>> test;
}