문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
springframework:springboot:batch [2018/07/25 18:21] kwon37xi [BatchApplication 구성] |
springframework:springboot:batch [2021/09/06 16:06] (현재) kwon37xi |
||
|---|---|---|---|
| 줄 6: | 줄 6: | ||
| 아래는 SpringBoot 에서 명령행(Command line)으로 Spring Batch Job을 실행하는 방법이다. | 아래는 SpringBoot 에서 명령행(Command line)으로 Spring Batch Job을 실행하는 방법이다. | ||
| - | ===== 의존성 및 bootJar 설정(Boot 2.x 기준) | + | * [[https:// |
| + | |||
| + | ===== 의존성 및 bootJar 설정 ===== | ||
| <code groovy> | <code groovy> | ||
| compile(' | compile(' | ||
| + | // 2.x | ||
| bootJar { | bootJar { | ||
| mainClassName = " | mainClassName = " | ||
| + | } | ||
| + | |||
| + | // 1.x - 지정하지 않으면 자동으로 @SpringBootApplication 애노테이션이 붙은 클래스로 자동 지정됨. | ||
| + | bootRepackage { | ||
| + | mainClass = " | ||
| } | } | ||
| </ | </ | ||
| 줄 21: | 줄 29: | ||
| * **'' | * **'' | ||
| * '' | * '' | ||
| - | * Program 인자로 '' | + | |
| * 기본적으로 '' | * 기본적으로 '' | ||
| 줄 31: | 줄 39: | ||
| public class BatchApplication extends DefaultBatchConfigurer { | public class BatchApplication extends DefaultBatchConfigurer { | ||
| public static void main(String[] args) { | public static void main(String[] args) { | ||
| - | | + | |
| + | System.exit(exitCode); | ||
| } | } | ||
| | | ||
| 줄 56: | 줄 65: | ||
| </ | </ | ||
| + | > '' | ||
| + | > DataSourceTransactionManagerAutoConfiguration.DataSourceTransactionManagerConfiguration 가 작동하지 않게 된다. | ||
| + | > 따라서 항상 **애플리케이션용 DataSource에 대한 transactionManager를 항상 명시적으로 만들어주고 @Primary 설정**을 해줘야 한다. | ||
| ===== 예제 Batch Job Configuration ===== | ===== 예제 Batch Job Configuration ===== | ||
| 줄 110: | 줄 122: | ||
| job: | job: | ||
| enabled: true | enabled: true | ||
| + | initialize-schema: | ||
| + | main: | ||
| + | web-application-type: | ||
| </ | </ | ||
| + | * '' | ||
| + | * SpringBoot 2.x 기준, '' | ||
| + | * Spring Batch 를 integraition test 할 때 '' | ||
| ===== 실행 ===== | ===== 실행 ===== | ||
| '' | '' | ||
| 줄 123: | 줄 140: | ||
| </ | </ | ||
| - | **'' | + | * **'' |
| + | * **'' | ||
| + | ===== 완전 auto configuration ===== | ||
| + | * 완전히 AutoConfig 로 SpringBoot batch 를 설정할 때 '' | ||
| + | |||
| + | ==== spring-boot-starter-batch-web ==== | ||
| + | * [[https:// | ||
| + | * SpringBoot Web으로 batch Job 실행. | ||
| + | |||
| + | |||
| + | ===== 참고 ===== | ||
| + | * [[https:// | ||
| + | * [[https:// | ||