我已定义了footercallback,但页脚信息未写入文件。 这是配置和代码。我错过了什么吗? 调用后脚步并将WriteCount写入日志但不写入文件。 工作def:
<job id="sodfeed" job-repository="tplJobRepository" xmlns="http://www.springframework.org/schema/batch">
<step id="readWriteBalances">
<tasklet>
<chunk reader="balancesReader" writer="balancesWriter" commit-interval="100" >
</chunk>
<listeners>
<listener ref="tplBatchFooterCallback" />
<listener ref="tplBatchFailureListener" />
</listeners>
</tasklet>
</step>
</job>
public class FooterCallback extends StepExecutionListenerSupport implements FlatFileFooterCallback{
private StepExecution stepExecution;
public void writeFooter(Writer writer) throws IOException {
writer.write("EOF" + stepExecution.getWriteCount());
System.out.println("**************************EOF" + stepExecution.getWriteCount());
}
public ExitStatus afterStep(StepExecution stepExecution) {
ExitStatus returnStatus = stepExecution.getExitStatus();
logger.info("Number of records written:"+stepExecution.getWriteCount());
return returnStatus;
}
}
答案 0 :(得分:0)
tplBatchFooterCallback
正确注入了FlatFileItemWriter
吗?听众和回调以不同的方式使用。