Previously, we were using Spring Batch 3.0.6 and tried to update it to 4.1.1. I have a job with only an ItemReader
and an ItemProcessor
- no ItermWriter
provided. It was working fine before update.
Now, I am getting:
java.lang.IllegalStateException: ItemWriter must be provided.
What is changed from previous version?
<job id="myJob" parent="baseJob">
<step id="myStep" parent="baseStep">
<tasklet>
<chunk reader="myItemReader" processor="myProcessor"
commit-interval="1" skip-limit="100000" retry-limit="1">
<skippable-exception-classes>
<include class="ExceptionClass"/>
</skippable-exception-classes>
<retryable-exception-classes>
<include class="ExceptionClass"/>
</retryable-exception-classes>
</chunk>
</tasklet>
<listeners merge="true">
<listener ref="promotionListener"/>
<listener ref="skippableExceptionListener"/>
</listeners>
</step>
</job>
ItemWriter. It is the element of the step of a batch process which writes data. An ItemWriter writes one item a time. Spring Batch provides an Interface ItemWriter. All the writers implement this interface.
ItemWriter defines the batch artifact that writes to a list of items for chunk processing.
FlatFileItemWriter is the ItemWriter implementation provided to generate text file output. Similar to FlatFileItemReader in many respects, this class addresses the issues with file-based output in Java with a clean, consistent interface for you to use.
ItemWriter
become mandatory in BATCH-2624
. Based on the information from the issue link , this change takes effect after version 3.0.10
, 4.0.2
and 4.1.0
If you really do not need an ItemWriter
, you can implement a dummy one:
public class NoOpItemWriter implements ItemWriter<Object>{
@Override
public void write(List<? extends Object> items) throws Exception {
}
}
And configure to use it:
<bean id="noOpItemWriter" class="org.foo.bar.NoOpItemWriter"/>
<chunk reader="myItemReader" processor="myProcessor" writer="noOpItemWriter">
.....
</chunk>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With