猿问

FlatFileItemReader 使用 FixedLengthTokenizer 不起作用

我正在 SpringBatch 中使用带有 FixedLengthTokenizer 的 FlatFileItemReader 来从文本文件中读取并保存到 xml 文件中。我收到一个错误:Bean 属性 'fixedLengthTokenizer' 不可写或具有无效的 setter 方法。setter 的参数类型是否与 getter 的返回类型匹配?(我会放孔控制台日志)。感谢您的任何帮助 。配置文件:spring-batch-context.xml:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xmlns:batch="http://www.springframework.org/schema/batch"

    xmlns:context="http://www.springframework.org/schema/context" 

xsi:schemaLocation=" http://www.springframework.org/schema/beans   

http://www.springframework.org/schema/beans/spring-beans-3.2.xsd

http://www.springframework.org/schema/batch 

http://www.springframework.org/schema/batch/spring-batch-3.0.xsd">

    <bean id="dataSource1"  class="org.springframework.jdbc.datasource.DriverManagerDataSource">

           <property name="driverClassName" value="oracle.jdbc.OracleDriver"></property>

           <property name="url" value="********"></property>

           <property name="password" value="*****"></property>

           <property name="username" value="******"></property>

         </bean>  

         <bean id="dataSource2"  class="org.springframework.jdbc.datasource.DriverManagerDataSource">

           <property name="driverClassName" value="oracle.jdbc.OracleDriver"></property>

           <property name="url" value="*******"></property>

           <property name="password" value="*****"></property>

           <property name="username" value="*****"></property>

         </bean>


     <bean id="flatFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader"  scope="step">


        <property name="resource" value="txt/flatfile" />

        <property name="lineMapper">


qq_遁去的一_1
浏览 276回答 1
1回答

慕慕森

在配置 spring bach 文件中: spring-batch-context.xml :我改变了这个:<property name="fixedLengthTokenizer">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<bean class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <property name="names" value="fisrtName,id, phone,lastName ,streetName,age,city, date_of_birth,quantity,sin ,code"></property>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <property name="columns" value="1-4,6-9,10-13,15-18,19-22,23-26,27-31,33-40,45-47,48-53,55-55"></property>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</bean>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </property>到 :<property name="lineTokenizer">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<bean class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <property name="names" value="fisrtName,id, phone,lastName ,streetName,age,city, date_of_birth,quantity,sin ,code"></property>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <property name="columns" value="1-4,6-9,10-13,15-18,19-22,23-26,27-31,33-40,45-47,48-53,55-55"></property>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</bean>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </property>它工作正常。
随时随地看视频慕课网APP

相关分类

Java
我要回答