From 5724af016b10b0f73b6d898ab0c826d421ec8e13 Mon Sep 17 00:00:00 2001 From: qibaoguang Date: Wed, 8 Apr 2015 00:09:47 +0800 Subject: [PATCH] Update 69.1. Execute Spring Batch jobs on startup.md --- .../69.1. Execute Spring Batch jobs on startup.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/IX. ‘How-to’ guides/69.1. Execute Spring Batch jobs on startup.md b/IX. ‘How-to’ guides/69.1. Execute Spring Batch jobs on startup.md index e69de29..68846ce 100644 --- a/IX. ‘How-to’ guides/69.1. Execute Spring Batch jobs on startup.md +++ b/IX. ‘How-to’ guides/69.1. Execute Spring Batch jobs on startup.md @@ -0,0 +1,10 @@ + +### 69.1. 在启动时执行Spring Batch作业 + +你可以在上下文的某个地方添加`@EnableBatchProcessing`来启用Spring Batch的自动配置功能。 + +默认情况下,在启动时它会执行应用的所有作业(Jobs),具体查看[JobLauncherCommandLineRunner](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java)。你可以通过指定`spring.batch.job.names`(多个作业名以逗号分割)来缩小到一个特定的作业或多个作业。 + +如果应用上下文包含一个JobRegistry,那么处于`spring.batch.job.names`中的作业将会从registry中查找,而不是从上下文中自动装配。这是复杂系统中常见的一个模式,在这些系统中多个作业被定义在子上下文和注册中心。 + +具体参考[BatchAutoConfiguration](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java)和[@EnableBatchProcessing](https://github.com/spring-projects/spring-batch/blob/master/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java)。