我Spring Batch
在Spring Boot
应用程序中使用。Spring Boot
版本1.3.5.RELEASE
是.
我正在尝试使用CompositeItemWriter
,以便首先由 WriterOne 压缩/压缩项目列表,然后将其传递给 WriterTwo,然后将它们写入数据库。
这是我的作家1:
@Component
public class Writer1 implements org.springframework.batch.item.ItemWriter<SimpleObject> {
@Override
public void write(List<? extends SimpleObject> list) throws Exception {
for(SimpleObject simpleObject: list){
// code which compresses the file
}
}
}
这是我的作家2:
@Component
public class Writer2 implements org.springframework.batch.item.ItemWriter<SimpleObject> {
@Override
public void write(List<? extends SimpleObject> list) throws Exception {
for(SimpleObject simpleObject: list){
// the file object meta data are being writtren to database.
}
}
}
这是我正在尝试初始化任务步骤并为其提供 CompositeItemWriter 而不是 ItemWriter。
CompositeItemWriter compositeItemWriter = new CompositeItemWriter();
compositeItemWriter.setDelegates(Arrays.asList(writer1,writer2));
TaskletStep processingStep = stepBuilderFactory.get(getLabel() + "-" + UUID.randomUUID().toString())
.<SimpleObject, SimpleObject>chunk(5)
.reader(reader)
.processor(processor)
.writer(compositeItemWriter).transactionManager(txManager).build();
然后代码给出编译时错误:
Error:(337, 83) java: cannot find symbol
symbol: method build()
location: class org.springframework.batch.core.step.builder.StepBuilderHelper