Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I am getting error Table 'test.batch_job_instance' doesn't exist

Tags:

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?

like image 965
prakash kumar Avatar asked Mar 23 '18 06:03

prakash kumar


People also ask

Does Spring Batch Auto create metadata tables?

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.

Does Spring Batch need a database?

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.

How do I disable spring batch job enabled?

To disable auto-run of jobs, you need to use spring. batch. job. enabled property in application.


1 Answers

If you are using Sprint boot a simple property in your application.properties will solve the issue spring.batch.initialize-schema=ALWAYS

like image 147
Nandhini Avatar answered Sep 24 '22 12:09

Nandhini