I'm launching a spring-batch job on application start using
spring.batch.job.names=MyJob
@Configuration
public class MyJob {
@Bean
public Job testJob() throws IOException {
return jobBuilderFactory.get(MyJob.class.getSimpleName())
.start(import())
.build();
}
}
Unfortunately this somehow delays the tomcat server startup. The job has a runtime of several minutes, thus I'm getting the following error:
Server Tomcat v8.0 Server at localhost was unable to start within 45 seconds. If the server requires more time, try increasing the timeout in the server editor.
Question: how can I run this job without preventing tomcat to start up? Eg running the job async?
You can include a ServletContextListener.
Put your code in the contextInitialized method.
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