我正在使用spring 3.0并尝试对Map<String ,String>
以下是配置和设置方法: Spring配置如下:
<bean name="geocoder" class="com.g1.component.igeocode.RemoteGeocoder" >
<property name="geocoderConverters">
<map>
<entry key="Default" value="com.g1.component.igeocode.mapmarker.DefaultGeocoderConverter"/>
<entry key="4.8.1.51" value="com.g1.component.igeocode.mapmarker.GeocoderConverter_v4_8_1_51"/>
</map>
</property>
</bean>
RemoteGeocoder.java
private Map<String, String> geocoderConverters;
public Map<String, String> getGeocoderConverters() {
return geocoderConverters;
}
public void setGeocoderConverters(Map<String, String> geocoderConverters) {
this.geocoderConverters = geocoderConverters;
}
但我在运行时遇到错误:
Error creating bean with name 'geocoder' defined in URL [file:/E:/Spectrum code/Spectrum 7/cdqplatform/platform/server/dist/target/g1server/server/app/tmp/igeocode-global-7.0.car-1643772799809108204-contents/resourcestage-config.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'geocoderConverters' threw exception; nested exception is java.lang.IllegalStateException: No Method invoker set on com.g1.component.igeocode.RemoteGeocoder@12a6f35
有人可以对此有所了解吗?
感谢。
答案 0 :(得分:1)
尝试将键和值类型指定为String
:
<property name="geocoderConverters">
<map key-type="java.lang.String" value-type="java.lang.String" map-class="java.util.HashMap">
<entry key="Default" value="com.g1.component.igeocode.mapmarker.DefaultGeocoderConverter"/>
<entry key="4.8.1.51" value="com.g1.component.igeocode.mapmarker.GeocoderConverter_v4_8_1_51"/>
</map>
</property>