Simple 1 Step Spring Batch Job without A reader (Writer only) possible?

Viewed 7338

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();

}

}
1 Answers
Related