我尝试在 Spring Batch 中使用 PoiItemreader 处理一个 excel 文件。当 excel 文件较小或正常大小时,程序成功运行。但是,当我尝试处理更大的文件(大于 12MB)时。该文件根本没有被读取。
我有以下问题:
- 使用 PoiItemreader 的文件大小限制是多少?
- 使用 MultiResourcePartioner 可以解决这个问题吗?
非常感谢你。
这是我的代码:
@Configuration
@EnableBatchProcessing
public class BatchConfiguration {
@Autowired
public JobBuilderFactory jobBuilderFactory;
@Autowired
public StepBuilderFactory stepBuilderFactory;
@Bean
public Job csvProcessJob() throws FileNotFoundException {
return jobBuilderFactory.get("csvProcessJob")
.incrementer(new RunIdIncrementer())
.flow(csvProcessStep())
.end()
.build();
}
@Bean
public Step csvProcessStep() throws FileNotFoundException {
return stepBuilderFactory.get("stepCSVprocess")
.<String, Map<String, AttributeValue>> chunk(25)
.reader(excelReader())
.processor(processor())
.writer(writer())
.build();
}
@Bean
public PoiItemReader excelReader() throws FileNotFoundException {
PoiItemReader reader = new PoiItemReader();
reader.setLinesToSkip(1);
reader.setResource(new ClassPathResource("file_name.xls"));
reader.setRowMapper(excelRowMapper());
return reader;
}
private RowMapper<MetaData> excelRowMapper() {
return new MetaDataRowMapper();
}
@Bean
public ItemProcessor<MetaData,Map<String,AttributeValue>> processor() {
return new MapProcessor();
}
@Bean
public ItemWriter writer() {
return new AWSwriter();
}