사용자 도구

사이트 도구


springframework:batch

문서의 이전 판입니다!


Spring Framework Batch

JobRepository

  • org.springframework.batch.core.repository.support.JobRepositoryFactoryBeanSimpleJobRepository 생성
  • MapJobRepositoryFactoryBean 로 in memory Job Repository 생성 가능.
  • org.springframework.batch.core 패키지에 schema-*.sql 파일이 Batch Job Repository DB 스키마이다.
  • schema-mysql.sql의 경우
    • textlongtext
    • datetimedatetime(6)로 변경해서 실행할 것.

Migration

Transaction 설정

트랜잭션 매니저를 지정하지 않으면

TransactionManager를 지정하지 않으면 다음과 같은 오류가 발생한다.

java.lang.IllegalStateException: To use the default BatchConfigurer the context must contain precisely one DataSource, found X

트랜잭션 기본 설정 및 트랜잭션 없이 실행하기

TransactionManager 를 ResourcelessTransactionManager 로 지정하면 된다.

혹은 아래와 같이 propagation=“NEVER”로 지정한다.

<batch:job id="jobid">
    <batch:step id="step1">
        <batch:tasklet ref="taskletId" transaction-manager="transactionManager">
            <batch:transaction-attributes propagation="NEVER"/>
        </batch:tasklet>
    </batch:step>
</batch:job>

Java Config

  • Step 등을 생성할 때 @Value(“#{jobParameter[paramName]}” String param 형태로 Job Parameter를 받을 수 있다.
@Bean
@JobScope
public Step myStep(@Value("#{jobParameters[date]}" String date, 
    @Value("#{jobParameters[count]}") long count) {
    // ...
}
springframework/batch.1530689102.txt.gz · 마지막으로 수정됨: 2018/07/04 16:25 저자 kwon37xi