Spring batch 可跳过异常
我尝试使用以下配置跳过批处理运行期间的所有异常:Spring batch 可跳过异常,spring-batch,Spring Batch,我尝试使用以下配置跳过批处理运行期间的所有异常: <chunk reader="aaaFileReader" writer="aaaDBWriter" commit-interval="100" skip-limit="100000"> <skippable-exception-classes> <include class="java.lang.Exceptio
<chunk reader="aaaFileReader" writer="aaaDBWriter"
commit-interval="100" skip-limit="100000">
<skippable-exception-classes>
<include class="java.lang.Exception" />
<exclude
class="org.springframework.jdbc.CannotGetJdbcConnectionException" />
</skippable-exception-classes>
</chunk>
<listeners>
<listener ref="aaabatchFailureListener" />
</listeners>
根据Spring批处理文档,一些异常不符合可跳过的条件
在您的情况下,从日志中可以清楚地看到,org.springframework.batch.item.file.FlatFileParseException
不是可跳过的例外,因此重新抛出org.springframework.batch.core.step.skip.nonskipablereadexception
阅读更多关于以下内容的章节: 对于遇到的任何异常,可跳过性将由类层次结构中最近的超类确定。任何未分类的异常都将被视为“致命” 阅读更多关于这方面的内容,如: 无法跳过读取操作时引发的致命异常
您可以在批处理作业配置中添加FlatFileParseException类,例如:
<batch:chunk reader="customImportReader" writer="customImporter" processor="customProcessor" commit-interval="1" skip-limit="10">
<batch:skippable-exception-classes>
<batch:include class="org.springframework.batch.item.file.FlatFileParseException" />
</batch:skippable-exception-classes>
</batch:chunk>
[您可以跳过类似这样的flatfile或NonSkippableReadException异常]()如果不使用XML配置,我发现这很有用:
<batch:chunk reader="customImportReader" writer="customImporter" processor="customProcessor" commit-interval="1" skip-limit="10">
<batch:skippable-exception-classes>
<batch:include class="org.springframework.batch.item.file.FlatFileParseException" />
</batch:skippable-exception-classes>
</batch:chunk>