Java Beforestep注释不接受参数
我对在Spring批处理的ItemReader中使用@Beforestep有点困惑 当我使用Java Beforestep注释不接受参数,java,spring,spring-batch,spring-boot,Java,Spring,Spring Batch,Spring Boot,我对在Spring批处理的ItemReader中使用@Beforestep有点困惑 当我使用 public class MyItemReader implements ItemReader<String> { long teller = 0L; @BeforeStep public void beforeStep(StepExecution se) { } @Override public String read() throws
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);
}
}
这种情况不会导致异常:
Caused by: java.lang.IllegalArgumentException: The method [beforeStep] on target class [MyItemReader] is incompatible with the signature [(StepExecution)] expected for the annotation [BeforeStep].
@BeforeStep
public void beforeStep() {
}
但是,文档中描述了第一种情况
人们期望什么?当无法将SendExecution对象添加到参数列表时,如何将其发送到该对象
我使用的是spring-boot-starter-batch-1.1.6。发布版解决了这个问题。有两个StepExecution类:
org.springframework.batch.core.StepExecution
和javax.batch.runtime.StepExecution
使用第一个,而不是第二个(像我那样)。您是否将bean设置为scope=“step”
?不,我没有。现在我尝试这样做,但仍然是相同的错误。您可以使用这样的xml<代码>。如果没有范围步骤,您可以定义一个单例bean。您可以发布作业的其余配置吗?