Just to implement a custom Batch Configuration for Spring Batch 5, following the official documentation on Blog: Spring Batch 5 Milestone 6 and JavaDoc Spring Batch 5 Milestone 8, I wrote this code, using Spring Batch 5 via Spring Boot 3 RC1:
@Configuration
class MyBatchConfiguration extends DefaultBatchConfiguration {
@Override
protected DataFieldMaxValueIncrementerFactory getIncrementerFactory() {
return new MyDataFieldMaxValueIncrementerFactory();
}
}
But I only get an error about my MyBatchConfiguration#jobRepository Bean, illegally overriding the JobRepositoryFactoryBean#jobRepository Bean. Which is weird, because JobRepositoryFactoryBean has no jobRepository.
Does anyone know how to solve this?
Error:
ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'jobRepository' defined in class path resource [my/package/MyBatchConfiguration.class]: @Bean definition illegally overridden by existing bean definition: Generic bean: class [org.springframework.batch.core.repository.support.JobRepositoryFactoryBean]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodNames=null; destroyMethodNames=null
Edit: I built a demo project under https://github.com/JD-CSTx/SpringBatchBugJobRepo.