组合来自 2 个文件的行并使用 Spring Batch 写入数据库 [英] Combine rows from 2 files and write to DB using Spring Batch

查看:23
本文介绍了组合来自 2 个文件的行并使用 Spring Batch 写入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 File1.csv,列有 id、name、age.File2.csv 有列 id,designation.在这两个文件中,ID 指的是相同的值并且是唯一的.样本数据文件 1.csv

I have File1.csv, with the columns id,name,age. File2.csv has the columns id,designation. In both the files ID refers to same value and is unique. Sample data File1.csv

id    name    age
101   abc     30
102   def     25

File2.csv

id     designation
101    manager
102    Assistant manager

Spring 批处理应该同时读取文件,合并数据并写入数据库,如下所示

Spring batch should read the files simultaneously, combine the data and write to DB as below

id   name    age   designation
101  abc     30     manager
102  def     25     Assistant manager

spring batch 如何同时读取2个文件?

How to read 2 files simultaneously in spring batch?

推荐答案

您必须实现一个将两个文件合并在一起的 Reader.

You have to implement a Reader that merges the two files togehter.

在这里看看我的回答聚合处理器或聚合阅读器

在哪里我已经链接到类似问题的其他答案

where I have linked to other answers to a similar question

这篇关于组合来自 2 个文件的行并使用 Spring Batch 写入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆