Results 1 to 2 of 2

Thread: Problem with MultiResourceItemReader

  1. #1
    Join Date
    Aug 2010
    Posts
    4

    Default Problem with MultiResourceItemReader

    I have configured MultiResourceItemReader to read the data from many .csv file and write to one .txt file

    Here is the configuration for it

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

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:batch="http://www.springframework.org/schema/batch"
    xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schem...ng-aop-2.5.xsd
    http://www.springframework.org/schema/batch http://www.springframework.org/schem...-batch-2.1.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <import resource="MEMORY-JOBREPOSITORY.xml"/>

    <bean id="multiResourceReader" class="org.springframework.batch.item.file.MultiRe sourceItemReader"
    scope="step">
    <property name="resources" value="file:c:\data\input\*.csv" />
    <property name="delegate" ref="playerFileItemReader" />
    </bean>

    <bean id="playerFileItemReader"
    class="org.springframework.batch.item.file.FlatFil eItemReader" >
    <property name="lineMapper">
    <bean
    class="org.springframework.batch.item.file.mapping .DefaultLineMapper">
    <property name="lineTokenizer">
    <bean
    class="org.springframework.batch.item.file.transfo rm.DelimitedLineTokenizer">
    <property name="delimiter" value=","/>
    <property name="names" value="ID,lastName,firstName,position,debutYear,fi nalYear" />
    </bean>
    </property>

    <property name="fieldSetMapper">
    <bean class="com.ssga.bmudi.price.job.dao.PlayerFieldSet Mapper" />
    </property>
    </bean>
    </property>
    </bean>


    <bean id="playerFileItemWriter"
    class="org.springframework.batch.item.file.FlatFil eItemWriter">
    <property name="resource" value="file:c:\data\output\output.txt" />
    <property name="shouldDeleteIfExists" value="true"/>
    <property name="lineAggregator">
    <bean
    class="org.springframework.batch.item.file.transfo rm.DelimitedLineAggregator">
    <property name="delimiter" value="-"/>

    <property name="fieldExtractor">
    <bean
    class="org.springframework.batch.item.file.transfo rm.BeanWrapperFieldExtractor">
    <property name="names" value="fullName,careerLength"/>
    </bean>
    </property>

    </bean>
    </property>
    </bean>


    <batch:job id="PriceUploadJOB" job-repository="jobRepository" >

    <batch:step id="step0">
    <batch:tasklet transaction-manager="jobRepository-transactionManager" >
    <batch:chunk reader="multiResourceReader" writer="playerFileItemWriter"
    commit-interval="10" />
    </batch:tasklet>
    </batch:step>
    </batch:job>
    </beans>



    If I change the resourse property of MultiResourceItemReader to

    <property name="resources" value="file:c:\data\input\player.csv" />

    it is working

    Please help to configure this properly so that i can read multiple files

    Thanks,
    Joseph

  2. #2
    Join Date
    Jun 2005
    Posts
    4,232

    Default

    Maybe try a properly specified URL pattern, e.g. file:///c:/data/input/*.csv? Or don't use Windows.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •