diff --git a/batch-and-integration/src/main/java/edabatch/BatchConfiguration.java b/batch-and-integration/src/main/java/edabatch/BatchConfiguration.java index c01af53..0610a47 100644 --- a/batch-and-integration/src/main/java/edabatch/BatchConfiguration.java +++ b/batch-and-integration/src/main/java/edabatch/BatchConfiguration.java @@ -20,10 +20,11 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.Resource; +import org.springframework.core.io.UrlResource; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.web.client.HttpStatusCodeException; import org.springframework.web.client.RestTemplate; - +import java.io.File; import javax.sql.DataSource; @Configuration @@ -79,10 +80,11 @@ Job job(JobBuilderFactory jobBuilderFactory, @Bean @StepScope FlatFileItemReader fileReader( - @Value("file://#{jobParameters['file']}") Resource pathToFile) throws Exception { + @Value("file://#{jobParameters['file']}") File pathToFile) throws Exception { + Resource resource = new UrlResource(pathToFile.toURI()); return new FlatFileItemReaderBuilder() .name("file-reader") - .resource(pathToFile) + .resource(resource) .targetType(Contact.class) .delimited().names("fullName,email".split(",")) .build(); @@ -117,4 +119,4 @@ JdbcBatchItemWriter jdbcWriter(DataSource dataSource) { .sql("insert into CONTACT( full_name, email, valid_email ) values ( :fullName, :email, :validEmail )") .build(); } -} \ No newline at end of file +}