存储在数据库 - Spring批处理中处理的每一行的结果

时间:2013-11-21 22:12:27

标签: csv spring-batch jobs

我想使用Spring Batch for CSV Parsing->做一些处理 - >在db中存储作业的结果: 对于CSV中的每一行,它应该执行以下操作:

1) Read line of CSV file
2) parse it
3) use the parsed tokens to do some processing
4) Store the result(success/failure with reason) of this processing in database.

我是Spring-Batch的新手。我在网上看到了一些例子。但我没有看到逐行存储的结果。有人可以指导我这是否可以在Spring批次中使用?

提前致谢。

1 个答案:

答案 0 :(得分:1)

Spring批量逐行读取并逐行处理。但是,为了优化写入,我们立刻编写了所有块。如果要逐行处理文件,一次提交(并因此写入)每一行,您需要做的就是将commit-interval更改为1.

您可以通过Spring的“入门指南”了解有关如何开始使用Spring Batch的更多信息:http://spring.io/guides/gs/batch-processing/