Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 如何处理多个文件_Spring_Spring Batch - Fatal编程技术网

Spring 如何处理多个文件

Spring 如何处理多个文件,spring,spring-batch,Spring,Spring Batch,需要开发一个spring批处理多个平面文件并将其保存在数据库中 多个平面文件按节划分,如下所示 flat file1 // this is the format of content in the file with different sections [ADDRESS] 1234 2345 N U 2 temp1 tmp1 [name] 1234 Raghu Prasad > > another flat file Flat2 [State] 123

需要开发一个spring批处理多个平面文件并将其保存在数据库中 多个平面文件按节划分,如下所示

flat file1 // this is the format of content in the file with different sections [ADDRESS] 1234 2345 N U 2 temp1 tmp1 [name] 1234 Raghu Prasad > > another flat file Flat2 [State] 1234 india hyderabad 平面文件1 //这是包含不同部分的文件中的内容格式 [地址] 1234 2345 N U 2临时1 tmp1 [姓名] 1234 Raghu Prasad > >另一个平面文件Flat2 [国家] 1234印度海得拉巴 在这里,我必须从姓名中检索“Raghu”、“Prasad”,从地址中检索temp,从地址中检索tmp1,从1234为键的州中检索“hyderabad”


需要在数据库中保存1234的数据在spring batch中没有聚合三个文件的功能

这可以通过两种方式实现

1.通过spring batch,您可以将每个文件数据转储到3个单独的表中,然后通过连接所有三个表数据,您可以将合并的数据合并并持久化到单个表中

2.通过spring batch,您首先将数据从一个文件加载到数据库,然后在下一个文件加载spring batch“Item processor”时,您可以比较文件数据和要加载到特定行的数据库数据,并对第三个文件重复相同的操作,以此类推

注:就个人而言,我建议使用性能良好且节省时间的第一个流程