Spring 批处理中对读取 zip 下的多个文件的任何支持

Any support in Spring Batch for reading multiple files under zip

我正在寻找基于位置从多个文件加载人员记录。 Spring批处理有没有简单的支持加载多个名为location weise的文件? 简单 Country_people.zip -> Location1(文件夹 1)包含 3 个文本文件(people_education.txt、people_address.txt、people_income.txt)

 -> Location2 (folder2) containing 3 text files(people_education.txt, people_address.txt, people_income.txt)

 -> Location3 (folder3) containing 3 text files(people_education.txt, people_address.txt, people_income.txt)

您可以尝试使用Partitioner从多个文件中获取数据

https://docs.spring.io/spring-batch/docs/current/reference/html/scalability.html#partitioning

https://docs.spring.io/spring-framework/docs/4.0.0.RELEASE/javadoc-api/org/springframework/core/io/support/PathMatchingResourcePatternResolver.html

https://docs.spring.io/spring-batch/docs/current/api/org/springframework/batch/item/file/MultiResourceItemReader.html

public class CustomMultiResourcePartitioner implements Partitioner {
 
    @Override
    public Map<String, ExecutionContext> partition(int gridSize) {
        Map<String, ExecutionContext> map = new HashMap<>(gridSize);
        int i = 0, k = 1;
        for (Resource resource : resources) {
            ExecutionContext context = new ExecutionContext();
            Assert.state(resource.exists(), "Resource does not exist: " 
              + resource);
            context.putString(keyName, resource.getFilename());
            context.putString("opFileName", "output"+k+++".xml");
            map.put(PARTITION_KEY + i, context);
            i++;
        }
        return map;
    }
}