我正在使用resourceLoader.getResource
Spring Batch 应用程序从 AWS S3 读取文件,但出现以下异常:
Caused by: java.lang.IllegalStateException: Input resource must exist (reader is in 'strict' mode): class path resource [s3://myProduct/app/dev/product/input1]
我尝试了多种解决方案,例如 usingPathResource
和其他方法,但没有成功。有人可以帮我解决这个问题吗?请在下面找到我的reader
方法:
@Bean
@StepScope
public FlatFileItemReader<String> fileReader() {
String bucketName = "myProduct";
String key = "app/dev/product/input1";
FlatFileItemReader reader = new FlatFileItemReader<>();
reader.setResource(resourceLoader.getResource("s3://" +bucketName + "/" +key));
reader.setLineMapper(new DefaultLineMapper());
return reader;
}