1
votes

i have configured spring batch with multiresourceitemreader which delegated to flatfileitemreader.Even then the flatfileitemreader is explitly insisting to set resource. what would be the solution?

For reading multiple files from a directory we need to MultiResouceItemReader where we specify the directory resource location and then set the delegation to FlatFileItemReader to actually read the file.so there is no need to set a resource as we set when we just used FlatFileItemReader to read a single file. but when i am not setting the resouce(not specifying any file location) , while running it is giving error as : input resource must be set? I explored and many sites are not setting up the resource in FlatFileItemReader when reading multiple files.

for reference :

http://www.mkyong.com/spring-batch/spring-batch-multiresourceitemreader-example/ Please see the configuration for flatfileitemreader in "resources/spring/batch/jobs/job-read-files.xml" file.

1
Please rewrite or add more info or I think this question will be closed shortly... - Luca Basso Ricci
at least add the used spring xml/javaconfig - Michael Pralow

1 Answers

1
votes

You will have to use multiResourceReader in place of flatFileItemReader while defining batch:chunk tag.

For example:

<batch:chunk reader="multiResourceReader" writer="oracleItemWriter" processor="itemProcessor" commit-interval="1000">

Hope this helps!

Cheers, Pratik