This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Boot 4.0.0!

Spring Batch

Spring Boot offers several conveniences for working with Spring Batch, including running a Job on startup.

When building a batch application, the following stores can be auto-configured:

  • In-memory

  • JDBC

Each store has specific additional settings. For instance, it is possible to customize the tables prefix for the JDBC store, as shown in the following example:

  • Properties

  • YAML

spring.batch.jdbc.table-prefix=CUSTOM_
spring:
  batch:
    jdbc:
      table-prefix: "CUSTOM_"

To disable Spring Boot’s auto-configuration and take complete control of Spring Batch’s configuration, add @EnableBatchProcessing to one of your @Configuration classes or extend DefaultBatchConfiguration. This will cause the auto-configuration to back off, including initialization of Spring Batch’s database schema if you’re using the JDBC-based store. Spring Batch can then be configured using the @Enable*JobRepository annotation’s attributes rather than the previously described configuration properties.

To learn more about manually configuring Spring Batch, see the API documentation of:

For more information about Spring Batch, see the Spring Batch project page.

Running Spring Batch Jobs on Startup

When Spring Boot auto-configures Spring Batch, and if a single Job bean is found in the application context, it is executed on startup (see JobLauncherApplicationRunner for details). If multiple Job beans are found, the job that should be executed must be specified using spring.batch.job.name.

You can disable running a Job found in the application context, as shown in the following example:

  • Properties

  • YAML

spring.batch.job.enabled=false
spring:
  batch:
    job:
      enabled: false