Skip to content

Commit

Permalink
Merge pull request #34437 from fmbenhassine
Browse files Browse the repository at this point in the history
* pr/34437:
  Update Batch documentation

Closes gh-34437
  • Loading branch information
mhalbritter committed Mar 3, 2023
2 parents 3ea99d0 + 04bbbb4 commit f5a8a71
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@ By default, batch applications require a `DataSource` to store job details.
Spring Batch expects a single `DataSource` by default.
To have it use a `DataSource` other than the application’s main `DataSource`, declare a `DataSource` bean, annotating its `@Bean` method with `@BatchDataSource`.
If you do so and want two data sources, remember to mark the other one `@Primary`.
To take greater control, implement `BatchConfigurer`.
See {spring-batch-api}/core/configuration/annotation/EnableBatchProcessing.html[The Javadoc of `@EnableBatchProcessing`] for more details.
To take greater control, add `@EnableBatchProcessing` to one of your `@Configuration` classes or extend `DefaultBatchConfiguration`.
See the Javadoc of {spring-batch-api}/core/configuration/annotation/EnableBatchProcessing.html[`@EnableBatchProcessing`]
and {spring-batch-api}/core/configuration/support/DefaultBatchConfiguration.html[`DefaultBatchConfiguration`] for more details.

For more info about Spring Batch, see the {spring-batch}[Spring Batch project page].



[[howto.batch.running-jobs-on-startup]]
=== Running Spring Batch Jobs on Startup
Spring Batch auto-configuration is enabled by adding `@EnableBatchProcessing` to one of your `@Configuration` classes.
Spring Batch auto-configuration is enabled by adding `spring-boot-starter-batch` to your application's classpath.

If a single `Job` is found in the application context, it is executed on startup (see {spring-boot-autoconfigure-module-code}/batch/JobLauncherApplicationRunner.java[`JobLauncherApplicationRunner`] for details).
If multiple `Job` beans are found, the job that should be executed must be specified using configprop:spring.batch.job.name[].

To disable running a `Job` found in the application content, set the configprop:spring.batch.job.enabled[] to `false.`

See {spring-boot-autoconfigure-module-code}/batch/BatchAutoConfiguration.java[BatchAutoConfiguration] and {spring-batch-api}/core/configuration/annotation/EnableBatchProcessing.html[@EnableBatchProcessing] for more details.
See {spring-boot-autoconfigure-module-code}/batch/BatchAutoConfiguration.java[BatchAutoConfiguration] for more details.



Expand Down

0 comments on commit f5a8a71

Please sign in to comment.