Skip to content

Spring Batch 6.0 Migration Guide

Mahmoud Ben Hassine edited this page Jun 26, 2025 · 10 revisions

This document is meant to help you migrate your applications to Spring Batch 6.0. Spring Batch 6 does not change the minimum required Java version which remains Java 17+.

Major changes

Dependencies upgrade

Spring Batch 6 upgrades its Spring dependencies to the following versions:

  • Spring Framework 7
  • Spring Integration 4
  • Spring Data 4
  • Spring AMQP 4
  • Spring for Apache Kafka 4
  • Micrometer 1.15

Infrastructure beans configuration

Changes related to @EnableBatchProcessing

Before v6, the @EnableBatchProcessing annotation was tied to a JDBC-based infrastructure. This is not the case anymore. Two new annotations have been introduced to configure the underlying job repository: @EnableJdbcJobRepository and EnableMongoJobRepository.

Starting from v6, @EnableBatchProcessing allows you to configure common attributes for the batch infrastructure, while store-specific attributes can be specified with the new dedicated annotations. Here is an example to migrate a JDBC configuration from v5 to v6:

// v5
@EnableBatchProcessing(dataSourceRef = "batchDataSource", taskExecutorRef = "batchTaskExecutor")
class MyJobConfiguration {

	@Bean
	public Job job(JobRepository jobRepository) {
		return new JobBuilder("job", jobRepository)
                    // job flow omitted
                    .build();
	}
}
// v6
@EnableBatchProcessing(taskExecutorRef = "batchTaskExecutor")
@EnableJdbcJobRepository(dataSourceRef = "batchDataSource")
class MyJobConfiguration {

	@Bean
	public Job job(JobRepository jobRepository) {
		return new JobBuilder("job", jobRepository)
                    // job flow omitted
                    .build();
	}
}

Changes related to DefaultBatchConfiguration

Similar to the annotation-based approach, the programmatic model based on DefaultBatchConfiguration has been updated by introducing two new configuration classes to define store-specific attributes: JdbcDefaultBatchConfiguration and MongoDefaultBatchConfiguration.

Here is an example to migrate a JDBC configuration from v5 to v6:

// v5
class MyJobConfiguration extends DefaultBatchConfiguration  {

	@Bean
	public Job job(JobRepository jobRepository) {
		return new JobBuilder("job", jobRepository)
                    // job flow omitted
                    .build();
	}

        @Override
	protected DataSource getDataSource() {
	        return new MyBatchDataSource();
	}
}
// v6
class MyJobConfiguration extends JdbcDefaultBatchConfiguration  {

	@Bean
	public Job job(JobRepository jobRepository) {
		return new JobBuilder("job", jobRepository)
                    // job flow omitted
                    .build();
	}

        @Override
	protected DataSource getDataSource() {
	        return new MyBatchDataSource();
	}
}

Changes related to the default batch configuration

  • The DefaultBatchConfiguration now configures a "resourceless" batch infrastructure (ie a ResourcelessJobRepository and a ResourcelessTransactionManager). This is to remove the need for an additional dependency to an in-memory database for those who do not need batch meta-data.
  • The configuration of a JobExplorer bean has been removed. This is due to the fact that JobRepository now extends JobExplorer and there is no need for a JobExplorer bean anymore, which is now deprecated (See "Deprecated APIs" section).
  • The configuration of a JobLauncher has been replaced with a JobOperator. This is due to the fact that JobOperator now extends JobLauncher and there is no need for a JobLauncher bean anymore, which is now deprecated (See "Deprecated APIs" section).

Database schema updates

TBD

Deprecated APIs

The following APIs have been deprecated in version 6.0:

TBD

Please refer to the Javadoc of each API for more details about the suggested replacement.

Moved APIs

TBD

Removed APIs

The following APIs were deprecated in previous versions and have been removed in this release:

TBD

Moreover, the following APIs have been removed/updated without deprecation:

TBD

Pruning

TBD

Clone this wiki locally