문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 다음 판 양쪽 다음 판 | ||
springframework:batch [2018/04/30 16:38] kwon37xi [JobRepository] |
springframework:batch [2018/09/15 20:58] kwon37xi |
||
---|---|---|---|
줄 1: | 줄 1: | ||
====== Spring Framework Batch ====== | ====== Spring Framework Batch ====== | ||
+ | * [[springframework: | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | * [[https:// | ||
* Spring Batch 2.2 JavaConfig | * Spring Batch 2.2 JavaConfig | ||
* [[https:// | * [[https:// | ||
줄 22: | 줄 24: | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | |||
+ | ===== @EnableBatchProcessing ===== | ||
+ | * [[https:// | ||
+ | |||
+ | ==== DefaultBatchConfigurer ==== | ||
+ | * 설정 중 일부를 Override하고자 한다면 [[https:// | ||
+ | * '' | ||
+ | // 다른 configuration class 에서 DataSource 생성 - embedded 예제 | ||
+ | @Bean | ||
+ | public DataSource batchDataSource() { | ||
+ | return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2) | ||
+ | .addScript(" | ||
+ | .build(); | ||
+ | } | ||
+ | |||
+ | @EnableBatchProcessing | ||
+ | @Configuration | ||
+ | public class BatchApplication extends DefaultBatchConfigurer { | ||
+ | // dataSource 설정부분 override. transactionManager도 자동으로 생성함. | ||
+ | @Autowired | ||
+ | @Override | ||
+ | public void setDataSource(@Qualifier(" | ||
+ | super.setDataSource(batchDataSource); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | * '' | ||
===== JobRepository ===== | ===== JobRepository ===== | ||
줄 30: | 줄 62: | ||
* '' | * '' | ||
* '' | * '' | ||
+ | |||
===== Migration ===== | ===== Migration ===== | ||
* [[https:// | * [[https:// | ||
줄 57: | 줄 90: | ||
</ | </ | ||
</ | </ | ||
+ | |||
+ | ==== Java Config ==== | ||
+ | * Step 등을 생성할 때 '' | ||
+ | |||
+ | <code java> | ||
+ | @Bean | ||
+ | @JobScope | ||
+ | public Step myStep(@Value("# | ||
+ | @Value("# | ||
+ | // ... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== JobInstanceAlreadyCompleteException: | ||
+ | * Job은 Job + Job Parameter 로 Job Key 가 결정되는데 동일한 Job Key 일 경우 실행이 안된다. | ||
+ | * 따라서 Job Parameter를 다는 값으로 주거나 [[https:// | ||
+ | * [[https:// | ||
+ | * SpringBoot Batch 는 '' | ||
+ | <code java> | ||
+ | jobBuilderFactory.get(" | ||
+ | .start(step()) | ||
+ | . ..... | ||
+ | .incrementer(new RunIdIncrementer()) | ||
+ | .build(); | ||
+ | </ | ||
+ | |||