spring-batch - 带有文件参数的Spring批量写入异常
问题描述
我想将异常写入与项目编写器相同的文件中,但不起作用
// MyLitner
public static class MySkipListener implements SkipListener<CSCiviqueDTO, CSCiviqueDTO> {
private BufferedWriter bw = null;
public MySkipListener(File file) throws IOException {
bw= new BufferedWriter(new FileWriter(file, true));
}
@Override
public void onSkipInRead(Throwable throwable) {
if (throwable instanceof FlatFileParseException) {
FlatFileParseException flatFileParseException = (FlatFileParseException) throwable;
System.out.println("onSkipInRead =========> :");
try {
bw.write(flatFileParseException.getInput() + "; Step Vérifiez les colonnes !!");
bw.newLine();
bw.flush();
// fileWriter.close();
} catch (IOException e) {
System.err.println("Unable to write skipped line to error file");
}
}
}
解决方案
推荐阅读
- swift - 自定义类列表,快速更新视图
- c# - 具有混合属性的继承类列表
- python - 发送请求时出现 Content-Type 错误
- python - 将字典转换为数据框
- curl - gcloud pubsub:如何使用 curl 将 xml 有效负载发送到本地 GCF pubsub?
- xml - 在 db2 的存储过程中创建 XML
- java - 为什么 java webserver BufferedReader 在很多方面都失败了?
- javascript - 无法通过更改变量返回嵌套函数中的值(Javascript)
- angular - 尝试从父组件传递数据时无法识别@Input()
- c# - 通过名称 unity 的字符串访问脚本变量