2014-11-10 4 views
2

Spring 배치의 ItemReader에서 @Beforestep을 사용하는 것에 약간 혼란 스럽다.Beforestep annotation이 인수를 취하지 않는다

내가 사용하는 경우

public class MyItemReader implements ItemReader<String> { 

    long teller = 0L; 

    @BeforeStep 
    public void beforeStep(StepExecution se) { 
    } 

    @Override 
    public String read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { 

     if(teller == 11) 
     return null; 

     return String.valueOf(++teller); 
    } 
} 

나는 예외 어떻게해야합니까 :

@BeforeStep 
    public void beforeStep() { 
    } 

그러나, 첫 번째 상황에서 설명 :이 상황은 예외가 발생하지 않습니다

Caused by: java.lang.IllegalArgumentException: The method [beforeStep] on target class [MyItemReader] is incompatible with the signature [(StepExecution)] expected for the annotation [BeforeStep]. 

을 문서.

예상되는 내용은 무엇입니까? 그리고 어떻게 그것을 인수 목록에 추가 할 수없는 경우 SendExecution 객체를 객체에 보냅니 까? 나는 스프링 부팅 스타터 배치 1.1.6.RELEASE 사용하고

+0

bean을'scope = "step"'으로 설정 했습니까? – Xstian

+0

아니, 나는하지 않았다. 지금은 그렇게하려고했지만 여전히 같은 오류가 발생합니다. –

+0

다음과 같이 xml을 사용할 수 있습니다 ..'' 범위가 없으면 singleton bean을 정의합니다. – Xstian

답변

0

를 해결. 2 단계 실행 클래스가 있습니다 : org.springframework.batch.core.StepExecutionjavax.batch.runtime.StepExecution 두 번째 단계가 아닌 첫 번째 단계를 사용하십시오 (이전처럼).

관련 문제