org.springframework.beans.ConversionNotSupportedException:对于所需类型的类型字符串Range []

时间:2015-07-27 05:36:56

标签: spring-batch

我使用弹簧批来从平面文件中读取数据

<bean id="dataTokenizer"
    class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
    <property name="names"
        value="linkageId,recordValue,description,facilityName,invoiceId,purchaseOrderId" />
    <property name="columns"
        value="2-5,6-25,26-185,186-255,256-271,272-287" />
</bean>

Iam面临以下异常:

org.springframework.beans.factory.access.BootstrapException: Unable to initialize group definition. Group resource name [classpath*:springconfig/springconfig-apc.xml], factory key [ear.context]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ear.context' defined in URL [file:/C:/ccer/Project1/PNX/appEAR/properties/springconfig/springconfig-apc.xml]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataTokenizer' defined in class path resource [springconfig/springconfig-apc-domainmapper.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.batch.item.file.transform.Range[]' for property 'columns'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.batch.item.file.transform.Range] for property 'columns[0]': no matching editors or conversion strategy found

如果需要任何其他信息,请告诉我。

1 个答案:

答案 0 :(得分:1)

尝试添加以下bean定义。

来源 - http://docs.spring.io/spring-batch/1.1.x/spring-batch-docs/reference/html/spring-batch-infrastructure.html

 <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>