Open b4uazam opened 6 years ago
Hi TechPrimers, Thanks for your code share, I have couple of queries, answering my queries will be appreciated.
- We noticed the error as below with given code base, Please take a look: Caused by: java.lang.IllegalStateException: Input resource must exist (reader is in 'strict' mode): URL [file:/Users/apple/Downloads/spring-batch-example-1/src/main/resources/users.csv] at org.springframework.batch.item.file.FlatFileItemReader.doOpen(FlatFileItemReader.java:251) ~[spring-batch-infrastructure-3.0.9.RELEASE.jar:3.0.9.RELEASE] at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:144) ~[spring-batch-infrastructure-3.0.9.RELEASE.jar:3.0.9.RELEASE]... 76 common frames omitted PS: Hope you changed the file path in application.properties (I resolved this by adding mine) 2.Currently I am running this application by hardcording the resource input, and its runnign as expected, But how can I run this application to pick the source file((~5 millions records) from shared drive location, instead of pickign from resource folder, What changes are required for it?
3.What are the changes required to switch it to other data sources(sql server). ? Please suggest the code changes, thanks in advance.
You can replace this method in SpringBatchConfig.java
@Bean
public FlatFileItemReader<User> itemReader() {
FlatFileItemReader<User> flatFileItemReader = new FlatFileItemReader<>();
flatFileItemReader.setResource(new ClassPathResource("users.csv"));
flatFileItemReader.setName("CSV-Reader");
flatFileItemReader.setLinesToSkip(1);
flatFileItemReader.setLineMapper(lineMapper());
return flatFileItemReader;
}
what if i give the file from postman
Hi TechPrimers, Thanks for your code share, I have couple of queries, answering my queries will be appreciated.
2.Currently I am running this application by hardcording the resource input, and its runnign as expected, But how can I run this application to pick the source file((~5 millions records) from shared drive location, instead of pickign from resource folder, What changes are required for it?
3.What are the changes required to switch it to other data sources(sql server). ? Please suggest the code changes, thanks in advance.