【发布时间】:2019-03-18 00:06:36
【问题描述】:
我想将动态文件名传递给 onSkipInRead。 例子: 公共 MySkipListener(@Value("#{jobParameters['file']}") 字符串文件) 抛出 IOException { bw= new BufferedWriter(new FileWriter(file); System.out.println("MySkipListener =========> :"+bw); }
@Override
public void onSkipInRead(Throwable throwable) {
if (throwable instanceof FlatFileParseException) {
FlatFileParseException flatFileParseException = (FlatFileParseException) throwable;
try {
bw.write(flatFileParseException.getInput()+"; Step Vérifiez les colonnes !!");
bw.newLine();
bw.flush();
} catch (IOException e) {
System.err.println("Unable to write skipped line to error file"); }
}
}
谢谢。
【问题讨论】:
-
使用 Throwable 保存文件名。捕获异常并将文件名保存到 throwable 并在侦听器中使用它。
标签: spring-batch