Clarify Batch docs on the need for a DataSource and DB-based repository

Closes gh-48233
This commit is contained in:
Andy Wilkinson
2025-11-24 11:41:17 +00:00
parent 4d3e374ad1
commit 1761ff0ff4
2 changed files with 5 additions and 12 deletions
@@ -393,8 +393,8 @@
* xref:how-to:batch.adoc#howto.batch.specifying-a-data-source[#howto-spring-batch-specifying-a-data-source]
* xref:how-to:batch.adoc#howto.batch.specifying-a-data-source[#howto.batch.specifying-a-data-source]
* xref:how-to:batch.adoc#howto.batch.specifying-a-transaction-manager[#howto.batch.specifying-a-transaction-manager]
* xref:how-to:batch.adoc#howto.batch.storing-job-repository[#howto-spring-batch-storing-job-repository]
* xref:how-to:batch.adoc#howto.batch.storing-job-repository[#howto.batch.storing-job-repository]
* xref:reference:io/spring-batch.adoc#io.spring-batch[#howto-spring-batch-storing-job-repository]
* xref:reference:io/spring-batch.adoc#io.spring-batch[#howto.batch.storing-job-repository]
* xref:how-to:batch.adoc#howto.batch[#howto-batch-applications]
* xref:how-to:batch.adoc#howto.batch[#howto.batch]
* xref:how-to:build.adoc#howto.build.build-an-executable-archive-with-ant-without-using-spring-boot-antlib[#howto-build-an-executable-archive-with-ant]
@@ -9,9 +9,9 @@ This section addresses those questions.
[[howto.batch.specifying-a-data-source]]
== Specifying a Batch Data Source
By default, batch applications require a javadoc:javax.sql.DataSource[] to store job details.
Spring Batch expects a single javadoc:javax.sql.DataSource[] by default.
To have it use a javadoc:javax.sql.DataSource[] other than the applications main javadoc:javax.sql.DataSource[], declare a javadoc:javax.sql.DataSource[] bean, annotating its javadoc:org.springframework.context.annotation.Bean[format=annotation] method with javadoc:org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource[format=annotation].
Batch applications that store job details in an SQL database require a javadoc:javax.sql.DataSource[] bean.
A single javadoc:javax.sql.DataSource[] bean is required by default.
To have Spring Batch use a javadoc:javax.sql.DataSource[] other than the applications main javadoc:javax.sql.DataSource[], declare a javadoc:javax.sql.DataSource[] bean, annotating its javadoc:org.springframework.context.annotation.Bean[format=annotation] method with javadoc:org.springframework.boot.batch.jdbc.autoconfigure.BatchDataSource[format=annotation].
If you do so and want two data sources (for example by retaining the main auto-configured javadoc:javax.sql.DataSource[]), set the `defaultCandidate` attribute of the javadoc:org.springframework.context.annotation.Bean[format=annotation] annotation to `false`.
@@ -66,10 +66,3 @@ This allows them to be modified or removed.
NOTE: When you're using a custom javadoc:org.springframework.batch.core.JobParametersIncrementer[], you have to gather all parameters managed by the incrementer to restart a failed execution.
[[howto.batch.storing-job-repository]]
== Storing the Job Repository
Spring Batch requires a data store for the javadoc:org.springframework.batch.core.Job[] repository.
If you use Spring Boot, you must use an actual database.
Note that it can be an in-memory database, see {url-spring-batch-docs}/job.html#configuringJobRepository[Configuring a Job Repository].