-
Oct 29th, 2012, 05:43 PM
#1
Problem autowiring ItemWriter defined with scope="step"
Hi,
I have a problem when I try to @Autowired a bean of type FlatFileItemWriter. I need to calculate a directory name in execution time and assign this value to the "resource" property using late-binding. There's no problem to achive this, but, when my batch runs, I receive an exception when Spring context tries to @Autowired this bean inside my ItemProcessor (I need to use it directly in the ItemProcessor for functional design)
The exception is: There are many candidates of type org.springframework...FlatFileItemWriter.
If I use the @Qualifier then the error refers to another bean that has no sense with that error.
Thanks,
-
Oct 30th, 2012, 04:33 PM
#2
Crazy question...why are you trying to wire an ItemReader into an ItemProcessor? Why not use just a regular DAO? There is no benefits of using an ItemReader in this way.
-
Oct 30th, 2012, 05:35 PM
#3
Hi mminella,
I am autowiring an ItemWriter NOT an ItemReader.
Thanks,
Last edited by maxjuiz; Oct 31st, 2012 at 04:22 AM.
-
Oct 31st, 2012, 09:35 AM
#4
Either way, my question is valid. You shouldn't be trying to wire up ItemReader/ItemWriter components into your ItemProcessor. They carry extra weight that is unused and unnecessary. Just create and inject a DAO of somekind.
-
Oct 31st, 2012, 09:44 AM
#5
My ItemWriter works as "delegate". I couldn't write items during the process because I need to process all the items first to do some operations.
But the main question isn't the design of the process, the main question is why do an ItemWriter cannot be autowired if this bean is defined with late-binding? Spring Batch bug?
Thanks,
-
Oct 31st, 2012, 09:47 AM
#6
The function of autowiring isn't one of batch but of spring core, so it wouldn't be a batch bug. Can you post the code you're working with?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules