在一个step中,不管reader还是process,还是write,出现了指定的错误都可以跳过,继续执行后面的数据。
@Bean
public Step chunkStep(){
return stepBuilderFactory.get("chunkStep1")
.chunk(3)
.reader(fileItemReader())
.writer(list -> list.forEach(System.out::println))
.faultTolerant()
.retry(FlatFileParseException.class)
.retryLimit(3)
.noRetry(NullPointerException.class)
.skip(IOException.class) //跳过IOException类型的异常
.skipLimit(5) //指定做多跳过5次
.allowStartIfComplete(true)
.build();
}
skip与retry的区别:retry不能对reader抛出的异常进行retry,只能对process或者write抛出的异常进行retry;skip可以对reader或者process或者write抛出的异常进行skip。