We have the classes like below When the batch process started.reader and processor are getting executed.but writer is not getting executed(though there is some data) When we debug,we could see that Repository are not getting autowired into the Writer class.
Are we missing any there? @SpringBootApplication @EnableJpaRepositories class Application{ } @EnableBatchProcessing @Configuration class BatchConfiguration{ @Bean public Writer createWriter() new Writer(); }
@Bean @StepScope public Reader reader(){ return new Reader(); }@Bean @StepScope public Processor processor(){ return new Processor(); } @Bean public Job processJob(){ return jobBuilderFactory.get("process.job").flow(orderStep1()).end().build(); }
@Bean
public Step orderStep1(){
return jobBuilderFactory.get("orderStep").
@Transactional public void write(){ } } **Note : 1.If we comment @Transactional, execution control going to write method, but it's getting stuck at customerRepisitory.save() method. Any clues on what's happening here appreciated
- The same code executed perfectly in spring boot 1.5.9 and spring 4.3.18 but after upgrading to spring boot 2.2.4 and spring 5.2.3 it, this issue occurring**
Comment From: wilkinsona
Duplicates #20324
@Chandrajava75 please provide the requested sample in a zip attached to #20324 or by pushing it to a separate repository.