如前所述,您的阅读器需要进行“逐步”调整。您可以通过
@Scope("step")注释完成此操作。如果您将该注释添加到阅读器,则它应该对您有用,如下所示:import org.springframework.batch.item.ItemReader;import org.springframework.beans.factory.annotation.Value;import org.springframework.stereotype.Component;@Component("foo-reader")@Scope("step")public final class MyReader implements ItemReader<MyData> { @Override public MyData read() throws Exception { //... } @Value("#{jobParameters['fileName']}") public void setFileName(final String name) { //... }}该范围默认情况下不可用,但是如果您正在使用
batchXML名称空间,则该范围将不可用。如果不是这样,请根据Spring
Batch文档,在Spring配置中添加以下内容以使作用域可用:
<bean />



