Skip to content

Commit 5f987a6

Browse files
committed
Polish "Improve Spring Batch coverage in reference documentation"
See gh-19211
1 parent 6bd9b2e commit 5f987a6

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

spring-boot-project/spring-boot-docs/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,7 @@
15251525
<jooq-version>${jooq.version}</jooq-version>
15261526
<spring-boot-version>${revision}</spring-boot-version>
15271527
<spring-amqp-version>${spring-amqp.version}</spring-amqp-version>
1528+
<spring-batch-version>${spring-batch.version}</spring-batch-version>
15281529
<spring-data-couchbase-version>${flattenedpom.version.org.springframework.data.spring-data-couchbase}</spring-data-couchbase-version>
15291530
<spring-data-commons-version>${flattenedpom.version.org.springframework.data.spring-data-commons}</spring-data-commons-version>
15301531
<spring-data-jpa-version>${flattenedpom.version.org.springframework.data.spring-data-jpa}</spring-data-jpa-version>

spring-boot-project/spring-boot-docs/src/main/asciidoc/attributes.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353

5454
:spring-amqp-api: https://docs.spring.io/spring-amqp/docs/{spring-amqp-version}/api/org/springframework/amqp
5555
:spring-batch: https://spring.io/projects/spring-batch
56-
:spring-batch-api: https://docs.spring.io/spring-batch/apidocs/org/springframework/batch
56+
:spring-batch-api: https://docs.spring.io/spring-batch/docs/{spring-batch-version}/api/org/springframework/batch
57+
:spring-batch-docs: https://docs.spring.io/spring-batch/docs/{spring-batch-version}/reference/html/
5758
:spring-data: https://spring.io/projects/spring-data
5859
:spring-data-cassandra: https://spring.io/projects/spring-data-cassandra
5960
:spring-data-commons-api: https://docs.spring.io/spring-data/commons/docs/{spring-data-commons-version}/api/org/springframework/data

spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,38 +2107,40 @@ The preceding example overrides the default factory, and it should be applied to
21072107
A number of questions often arise when people use Spring Batch from within a Spring Boot application.
21082108
This section addresses those questions.
21092109

2110+
2111+
21102112
[[howto-spring-batch-specifying-a-data-source]]
21112113
=== Specifying a Batch Data Source
2112-
21132114
By default, batch applications require a `DataSource` to store job details.
2114-
Batch autowires a single `DataSource` in your context and uses that for processing.
2115-
To have Batch use a `DataSource` other than the application’s main `DataSource`, declare a `DataSource` bean, annotating its `@Bean` method with `@BatchDataSource`.
2116-
If you do so and want two data sources, remember to create another one and mark it as `@Primary`.
2115+
Spring Batch expects a single `DataSource` by default.
2116+
To have it use a `DataSource` other than the application’s main `DataSource`, declare a `DataSource` bean, annotating its `@Bean` method with `@BatchDataSource`.
2117+
If you do so and want two data sources, remember to mark the other one `@Primary`.
21172118
To take greater control, implement `BatchConfigurer`.
21182119
See {spring-batch-api}/core/configuration/annotation/EnableBatchProcessing.html[The Javadoc of `@EnableBatchProcessing`] for more details.
21192120

2120-
For more about Spring Batch, see the {spring-batch}[Spring Batch project page].
2121+
For more info about Spring Batch, see the {spring-batch}[Spring Batch project page].
2122+
2123+
21212124

2122-
[[howto-running-spring-batch-jobs-on-startup]]
2125+
[[howto-spring-batch-running-jobs-on-startup]]
21232126
=== Running Spring Batch Jobs on Startup
2124-
Spring Batch auto-configuration is enabled by adding `@EnableBatchProcessing` (from Spring Batch) somewhere in your context.
2127+
Spring Batch auto-configuration is enabled by adding `@EnableBatchProcessing` to one of your `@Configuration` classes.
21252128

21262129
By default, it executes *all* `Jobs` in the application context on startup (see {spring-boot-autoconfigure-module-code}/batch/JobLauncherCommandLineRunner.java[`JobLauncherCommandLineRunner`] for details).
21272130
You can narrow down to a specific job or jobs by specifying `spring.batch.job.names` (which takes a comma-separated list of job name patterns).
21282131

2129-
See {spring-boot-autoconfigure-module-code}/batch/BatchAutoConfiguration.java[BatchAutoConfiguration] and https://github.com/spring-projects/spring-batch/blob/master/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java[@EnableBatchProcessing] for more details.
2132+
See {spring-boot-autoconfigure-module-code}/batch/BatchAutoConfiguration.java[BatchAutoConfiguration] and {spring-batch-api}/core/configuration/annotation/EnableBatchProcessing.html[@EnableBatchProcessing] for more details.
2133+
2134+
21302135

21312136
[[howto-spring-batch-running-command-line]]
21322137
=== Running from the Command Line
2133-
21342138
Running Spring Batch with Spring Boot from the command line differs from running Spring Batch by itself from the command line.
2135-
Spring Boot uses a class called `JobLaunchingCommandLineRunner`.
2136-
Spring Batch uses a class called `CommandLineJobRunner`.
2137-
They work a bit differently. However, for the most part, the differences do not cause trouble.
2138-
However, they parse command line arguments differently, which can cause trouble, as described in the next section.
2139+
The most important difference is that they parse command line arguments differently, which can cause trouble, as described in the next section.
2140+
21392141

2140-
==== Passing Command-line Arguments
21412142

2143+
==== Passing Command-line Arguments
21422144
Spring Boot uses `--` (two hyphens) to signal application arguments.
21432145
Spring Batch uses a single hyphen as a special marker on the `jobParameters` argument.
21442146
This section explains how to reconcile that difference when you use the `jobParameters` argument for Spring Batch within a Spring Boot application.
@@ -2150,22 +2152,27 @@ However, in Spring Batch, putting a single `-` character before the `jobParamete
21502152
Best practice is to use the `jobParameters` value as the identifier for the `Job`, so this issue may cause problems.
21512153
To avoid the issue, you should generally use no `-` characters for the command-line options that you pass to Spring Boot on behalf of Spring Batch, as shown in the following example:
21522154

2153-
[source]
2154-
someParameter="someValue"
2155+
[source,properties,indent=0]
2156+
----
2157+
someParameter=someValue
2158+
----
21552159

2156-
However, if you mean to not use the `someValue` value as the identifier for the `Job`, use two hyphens, as shown in the following example:
2160+
However, if you mean to not use `someValue` value as the identifier for the `Job`, use two hyphens, as shown in the following example:
21572161

2158-
[source]
2159-
--jobParameters="someValue"
2162+
[source,properties,indent=0]
2163+
----
2164+
--jobParameters=someValue
2165+
----
21602166

21612167
In the second example, Spring Boot passes the parameter to Spring Batch as `-jobParameters="someValue"`, and `someValue` is used as a non-identifying job parameter.
21622168

2169+
2170+
21632171
[[howto-spring-batch-storing-job-repository]]
21642172
=== Storing the Job Repository
2165-
2166-
Spring Batch requires a memory store for the `Job` repository.
2167-
If you use Spring Boot, you must use an actual database. Note that it can be an in-memory database.
2168-
See https://docs.spring.io/spring-batch/trunk/reference/html/configureJob.html#configuringJobRepository[Configuring a Job Repository].
2173+
Spring Batch requires a data store for the `Job` repository.
2174+
If you use Spring Boot, you must use an actual database.
2175+
Note that it can be an in-memory database, see {spring-batch-docs}job.html#configuringJobRepository[Configuring a Job Repository].
21692176

21702177

21712178

0 commit comments

Comments
 (0)