I am new to Spring Batch. I have configured my job with inmemoryrepository. But still, it seems it is using DB to persist job Metadata. My spring batch Configuration is :
@Configuration public class BatchConfiguration { @Autowired private StepBuilderFactory stepBuilderFactory; @Autowired private JobBuilderFactory jobBuilder; @Bean public JobLauncher jobLauncher() throws Exception { SimpleJobLauncher job =new SimpleJobLauncher(); job.setJobRepository(getJobRepo()); job.afterPropertiesSet(); return job; } @Bean public PlatformTransactionManager getTransactionManager() { return new ResourcelessTransactionManager(); } @Bean public JobRepository getJobRepo() throws Exception { return new MapJobRepositoryFactoryBean(getTransactionManager()).getObject(); } @Bean public Step step1(JdbcBatchItemWriter<Person> writer) throws Exception { return stepBuilderFactory.get("step1") .<Person, Person> chunk(10) .reader(reader()) .processor(processor()) .writer(writer).repository(getJobRepo()) .build(); } @Bean public Job job( @Qualifier("step1") Step step1) throws Exception { return jobBuilder.get("myJob").start(step1).repository(getJobRepo()).build(); } }
How to resolve above issue?
The meta table's scripts are stored in the spring-batch. jar , you need to create it manually. Run your Spring batch jobs again, those meta tables will be created automatically.
Spring Batch by default uses a database to store metadata on the configured batch jobs. In this example, we will run Spring Batch without a database. Instead, an in-memory Map based repository is used.
To disable auto-run of jobs, you need to use spring. batch. job. enabled property in application.
If you are using Sprint boot a simple property in your application.properties will solve the issue spring.batch.initialize-schema=ALWAYS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With