Java 跳过进程上的记录
我使用SpringBatch将数据持久化到DB中。 我的情况是,如果记录是故障或错误记录,我必须跳过流程中的记录。假设我有500条记录,提交间隔是50。如果我在第40条记录处出错,那么只需跳过该记录,其余记录应保留到数据库中。我已经实现了跳过文件的跳过机制 这是我试图跳过的代码。此代码将跳过整个文件Java 跳过进程上的记录,java,spring-batch,Java,Spring Batch,我使用SpringBatch将数据持久化到DB中。 我的情况是,如果记录是故障或错误记录,我必须跳过流程中的记录。假设我有500条记录,提交间隔是50。如果我在第40条记录处出错,那么只需跳过该记录,其余记录应保留到数据库中。我已经实现了跳过文件的跳过机制 这是我试图跳过的代码。此代码将跳过整个文件 <batch:step id="SlavePromotion"> <batch:tasklet> <batch:chunk reader="pr
<batch:step id="SlavePromotion">
<batch:tasklet>
<batch:chunk reader="promotionFileXmlReader" writer="dbPromotionWriter"
commit-interval="50" skip-limit="10">
<batch:skippable-exception-classes>
<batch:include class="org.springframework.batch.item.file.FlatFileParseException"/>
<batch:include class="org.springframework.batch.core.step.skip.SkipException"/>
<batch:include class="org.springframework.jdbc.UncategorizedSQLException"/>
<batch:include class="org.springframework.dao.DuplicateKeyException"/>
<batch:include class="org.springframework.dao.EmptyResultDataAccessException"/>
</batch:skippable-exception-classes>
</batch:chunk>
</batch:tasklet>
</batch:step>
我在源文件夹中有两个xml文件
file-1
<Root>
<>Child1</>
<>Child2</>
<>Child3</>
</Root>
file-2
<Root>
<>Child4</>
<>Child5</>
<>Child6</>
</Root>
file-1
孩子1
孩子2
孩子3
文件-2
孩子4
孩子5
孩子6
我将提交间隔保持为“1”。当我处理文件时,从读卡器到写卡器,我的child2文件记录是重复记录。因此,它应该跳过第二条记录并继续使用child3。提交始终处于批处理级别。Spring要么成功提交整个批,要么失败整个批。配置中不支持只跳过一条记录的方案。在我们的示例中,整个文件都在跳过。它不会进入下一批。作业结束时,您将获得什么堆栈跟踪?