Spring @value属性:无法将 'java.util.Collections$UnmodifiableMap' 类型的值转换为所需的类型"java.util.Map



我有一个带有这个spring属性的服务:

@Value("#{${table.to.key.order.by: {'table': {'key' , 'order'}}}}")
private Map<String, Map.Entry<String, String>> tableToKeyOrderMap;

由于某些原因,我在启动时得到了这个错误:

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tableService': 
Unsatisfied dependency expressed through field 'tableToKeyOrderMap'; 
nested exception is org.springframework.beans.ConversionNotSupportedException: 
Failed to convert value of type 'java.util.Collections$UnmodifiableMap' to required type 'java.util.Map'; 
nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.util.Collections$UnmodifiableRandomAccessList' to required type 'java.util.Map$Entry': no matching editors or conversion strategy found

提前感谢任何输入!

尝试将值从@Value("#{${table.to.key.order.by: {'table': {'key' , 'order'}}}}")更改为@Value("#{${table.to.key.order.by: {'table': {'key' : 'order'}}}}")

{'key' , 'order'}读作List

相关内容

最新更新