CustomEditorConfigurer的customEditors属性,带有RangeArrayPropertyEditor,Spring 4.3.3 with Spring Batch 3.0.7

时间:2016-11-02 14:07:32

标签: java spring spring-batch

我正在使用带有Spring批处理3.0.7的Spring 4.3.3并获得此异常:

Caused by: org.springframework.beans.TypeMismatchException: Failed to
convert property value of type [java.util.LinkedHashMap] to required
type [java.util.Map] for property 'customEditors';  nested exception
is java.lang.IllegalArgumentException: Cannot convert value of type
[org.springframework.batch.item.file.transform.RangeArrayPropertyEditor]
to required type [java.lang.Class] for property 'customEditors[org.springframework.batch.item.file.transform.Range[]]':
PropertyEditor [org.springframework.beans.propertyeditors.ClassEditor]
returned inappropriate value of type
[org.springframework.batch.item.file.transform.RangeArrayPropertyEditor]

代码:

<bean id="customEditorConfigurer"
    class="org.springframework.beans.factory.config.CustomEditorConfigurer">
    <property name="customEditors">
        <map>
            <entry key="org.springframework.batch.item.file.transform.Range[]">
                <bean
                    class="org.springframework.batch.item.file.transform.RangeArrayPropertyEditor" />
            </entry>
        </map>
    </property>
</bean>

1 个答案:

答案 0 :(得分:0)

试试这个:

<bean id="customEditorConfigurer"
class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
    <map>
        <entry key="org.springframework.batch.item.file.transform.Range[]" value="org.springframework.batch.item.file.transform.RangeArrayPropertyEditor"/>
    </map>
</property>