3

私の春のバッチライターは、以下のようにフッターコールバックとステップ実行リスナーを実装しています:

public class MyItemWriter implements ItemWriter<MyBean>, FlatFileFooterCallback, StepExecutionListener, ItemStream

クラスにはプライベート String プロパティがあります。

private String one;

私の footerCallback と afterStep メソッドは次のとおりです。

public void writeFooter(Writer writer) throws IOException {
this.one = "this is a test";
}

public ExitStatus afterStep(StepExecution stepExecution) {
File file = new File("myFile");
try {
      FileUtils.write(file, this.one);          
 } catch (IOException e) {
      e.printStackTrace();
   } 
  return null;
}

明らかなように、プロパティ文字列を footerCallBack で 1 に設定し、それを afterStep メソッドで使用しています。

ただし、ファイルに null 値が書き込まれています。

デバッグ時に、afterStep メソッドが writeFooter の前に呼び出されていることがわかりました。

しかし、それは間違っていませんか?footerCallBack が終了した後にのみステップを完了すべきではありませんか?

4

0 に答える 0