From eaf2f7b62c19647880ef2912bcb73633a18e7883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=B8=E6=81=92=E4=B9=8B=E9=81=93?= <85309651@qq.com> Date: Wed, 18 Oct 2017 18:18:49 +0800 Subject: [PATCH 1/2] fix windows platform run error --- .../src/main/java/edabatch/BatchConfiguration.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/batch-and-integration/src/main/java/edabatch/BatchConfiguration.java b/batch-and-integration/src/main/java/edabatch/BatchConfiguration.java index c01af53..57dc007 100644 --- a/batch-and-integration/src/main/java/edabatch/BatchConfiguration.java +++ b/batch-and-integration/src/main/java/edabatch/BatchConfiguration.java @@ -23,7 +23,7 @@ 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 +79,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 +118,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 +} From 86eb05f8fead93cae2ae8037619dd71cc6f8ad44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=B8=E6=81=92=E4=B9=8B=E9=81=93?= <85309651@qq.com> Date: Wed, 18 Oct 2017 18:24:35 +0800 Subject: [PATCH 2/2] Update BatchConfiguration.java --- .../src/main/java/edabatch/BatchConfiguration.java | 1 + 1 file changed, 1 insertion(+) diff --git a/batch-and-integration/src/main/java/edabatch/BatchConfiguration.java b/batch-and-integration/src/main/java/edabatch/BatchConfiguration.java index 57dc007..0610a47 100644 --- a/batch-and-integration/src/main/java/edabatch/BatchConfiguration.java +++ b/batch-and-integration/src/main/java/edabatch/BatchConfiguration.java @@ -20,6 +20,7 @@ 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;