您好我们正在春季启动项目中集成spring批处理,但我面临此例外Scope 'step' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No context holder available for step scope
这里是我的步骤范围bean配置类:
@Bean
@StepScope
public StaxEventItemReader<Document> xmlFileItemReader(@Value("#{jobParameters[fullPathFileName]}") String pathToFile) {
StaxEventItemReader<Document> xmlFileReader = new StaxEventItemReader<>();
xmlFileReader.setResource(new FileSystemResource(pathToFile));
xmlFileReader.setFragmentRootElementName("Document");
Jaxb2Marshaller pimMarshaller = new Jaxb2Marshaller();
pimMarshaller.setClassesToBeBound(Document.class);
xmlFileReader.setUnmarshaller(pimMarshaller);
return xmlFileReader;
}
我的主要runnable类使用@EnableBatchProcessing
进行注释答案 0 :(得分:-1)
使用步进镜如下 XMl配置: