문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 다음 판 양쪽 다음 판 | ||
springframework:batch [2018/08/07 11:21] kwon37xi |
springframework:batch [2019/10/15 17:35] kwon37xi |
||
---|---|---|---|
줄 2: | 줄 2: | ||
* [[springframework: | * [[springframework: | ||
* [[http:// | * [[http:// | ||
+ | * [[https:// | ||
* [[http:// | * [[http:// | ||
+ | * [[https:// | ||
* Spring Batch 2.2 JavaConfig | * Spring Batch 2.2 JavaConfig | ||
* [[https:// | * [[https:// | ||
줄 26: | 줄 28: | ||
* [[https:// | * [[https:// | ||
* [[http:// | * [[http:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | |||
===== @EnableBatchProcessing ===== | ===== @EnableBatchProcessing ===== | ||
줄 53: | 줄 61: | ||
</ | </ | ||
* '' | * '' | ||
+ | * SpringBoot 에서 '' | ||
===== JobRepository ===== | ===== JobRepository ===== | ||
* '' | * '' | ||
줄 102: | 줄 110: | ||
</ | </ | ||
+ | ===== 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(); | ||
+ | </ | ||
+ | |||
+ | ===== RunIdIncrementer 사용시 기존 파라미터가 현재 파라미터 지정한 것을 덮어씀 | ||
+ | * '' | ||
+ | * 이유는 '' | ||
+ | * 따라서 '' | ||
+ | * [[https:// | ||
+ | |||
+ | <code java> | ||
+ | /** | ||
+ | * 파라미터를 복사하지 않는 RunIdIncrementer | ||
+ | */ | ||
+ | public class ParamCleanRunIdIncrementer implements JobParametersIncrementer { | ||
+ | private static String RUN_ID_KEY = " | ||
+ | private String key = RUN_ID_KEY; | ||
+ | |||
+ | public void setKey(String key) { this.key = key; } | ||
+ | |||
+ | @Override | ||
+ | public JobParameters getNext(JobParameters parameters) { | ||
+ | JobParameters params = (parameters == null) ? new JobParameters() : parameters; | ||
+ | long id = params.getLong(key, | ||
+ | return new JobParametersBuilder().addLong(key, | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Java Config Spring Bean 설정시 리턴 타입을 인터페이스가 아닌 구현 클래스로 지정할 것. ===== | ||
+ | * '' | ||
+ | * 따라서 Spring Batch 용 각 스텝별 Bean 을 생성해서 리턴할 때는 항상 **구현 클래스를 리턴 타입으로 지정**할 것. | ||
+ | * [[https:// | ||
+ | * 다음과 같은 WARN 을 볼 수도 있다. | ||
+ | |||
+ | > o.s.b.c.l.AbstractListenerFactoryBean | ||
+ | |||
+ | |||
+ | ===== Test ===== | ||
+ | * [[https:// | ||
+ | * 이 클래스는 static utility 가 아니라 Bean 으로 생성해줘야 하는 것이다. | ||
+ | * '' | ||
+ | * 특정 Step만 테스트도 가능함. | ||
+ | * [[springframework: | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | |||
+ | |||
+ | ===== 참고 ===== | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// |