I was wondering if it is possible to write a spring batch job that has a step that ONLY has a writer. I can't find any documentation on what is inherently necessary for a given step in the spring batch documentation.
I was hoping to do something like :
public class MyBatchConfiguration {
@Bean
public ItemWriter<myInfo> myWriter() {
return new MyWriter();
}
@Bean
public Step myStep(StepBuilderFactory stepBuilderFactory,
ItemWriter<? super Object> myWriter,
PlatformTransactionManager transactionManager) {
return stepBuilderFactory.get("myStep")
.chunk(1)
.writer(myWriter).
transactionManager(transactionManager).
build();
}
@Bean
public Job myBatch(JobBuilderFactory jobs, Step myStep, JobExecutionListener listener) {
return jobs.get("myBatch")
.incrementer(new RunIdIncrementer())
.flow(exceptionReporterStep)
.end()
.listener(listener)
.build();
}
}
In a word, no.
It seems like you likely should use a tasklet step rather than a "chunked" one.
@Bean
public Step myStep(StepBuilderFactory stepBuilderFactory,
Tasklet myTasklet,
PlatformTransactionManager transactionManager) {
return stepBuilderFactory.get("myStep")
.tasklet(myTasklet)
.transactionManager(transactionManager)
.build();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.