I am trying to migrate data between different MongoDB
databases and for this purpose create a simple demo. After fixing deprecated dependency errors (I use 'spring-batch-core', version: '5.1.2'
) related to Spring Batch
, now I am getting “Parameter 1 of constructor in BatchConfig required a bean of type ‘org.springframework.batch.core.repository.JobRepository’ that could not be found.” error in the BatchConfig
class shown below.
@Configuration
@RequiredArgsConstructor
// @EnableBatchProcessing
public class BatchConfig {
// public class BatchConfig extends DefaultBatchConfiguration {
private final StudentReactiveRepository studentReactiveRepository;
private final JobRepository jobRepository;
private final PlatformTransactionManager transactionManager;
@Bean
public ItemReader<Student> studentItemReader() {
Flux<Student> students = studentReactiveRepository.findAll();
return new IteratorItemReader<>(students.toIterable());
}
@Bean
public ItemWriter<Student> studentItemWriter() {
return students -> {
for (Student student : students) {
studentReactiveRepository.save(student).block();
}
};
}
@Bean
public Step processStudentStep() {
return new StepBuilder("processStudentStep", jobRepository)
.<Student, Student>chunk(10, transactionManager)
.reader(studentItemReader())
// .processor(processor())
.writer(studentItemWriter())
// .taskExecutor(taskExecutor())
.build();
}
@Bean
public Job studentProcessingJob() {
return new JobBuilder("studentProcessingJob", jobRepository)
.start(processStudentStep())
.build();
}
}
I have tried several workarounds as commented out in the config and some others, but still not fixed. Is there any workaround to fix the problem? I would also be appreciated if there is any suggestion for some implementation examples of migrating data between MongoD
databases using Spring Batch
?