Closed spring-projects-issues closed 10 years ago
Charles Lee commented
I have posted my comments in the forum (see reference URL above). This is not a bug.
MARTIN JUIZ commented
Hi Charles,
I just read your post and I'm gonna try it. I'll tell you the result...
Thanks in advance !!! :D
Regards,
MARTIN JUIZ opened BATCH-1905 and commented
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.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.
Why do an ItemWriter cannot be autowired if this bean is defined with late-binding?
==========================================================================
==========================================================================
The code is:
LISTENER TO BUILD THE DIRECTORY NAME:
@BeforeJob
void beforeJob(JobExecution jobExecution) { String dirTimestamp = BatchUtil.getInstance().getFormattedDate(new Date(), BatchConstants.DATE_FORMAT6); ExecutionContext executionContext = jobExecution.getExecutionContext(); executionContext.putString(batchConfig.nombreDirTi mestamp, dirTimestamp + "/"); }THE XML CONFIG OF THE JOB:
\
\
<step id="step1" ..../>
\ \
\
\
\
\
\
\
......................
\
THE ITEM PROCESS CODE:
@Autowired
FlatFileItemWriter\If I don't use the late-binding in the bean, there's no problem to autowired it.
Affects: 2.1.8
Reference URL: http://forum.springsource.org/showthread.php?131462-Problem-autowiring-ItemWriter-defined-with-scope-quot-step-quot