80. Batch applications

[Note]Note

By default, batch applications require a DataSource to store job details. If you want to deviate from that, you’ll need to implement BatchConfigurer, see The Javadoc of @EnableBatchProcessing for more details.

80.1 Execute Spring Batch jobs on startup

Spring Batch auto-configuration is enabled by adding @EnableBatchProcessing (from Spring Batch) somewhere in your context.

By default it executes all Jobs in the application context on startup (see JobLauncherCommandLineRunner for details). You can narrow down to a specific job or jobs by specifying spring.batch.job.names (comma-separated job name patterns).

If the application context includes a JobRegistry then the jobs in spring.batch.job.names are looked up in the registry instead of being autowired from the context. This is a common pattern with more complex systems where multiple jobs are defined in child contexts and registered centrally.

See BatchAutoConfiguration and @EnableBatchProcessing for more details.