Last active
April 30, 2019 06:43
-
-
Save Edijun/dfd734b4c67a763350fa8d987e2cdf4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
public FlatFileItemReader<Product> csvProductReader() { | |
FlatFileItemReader<Product> reader = new FlatFileItemReader<Product>(); | |
reader.setResource(new ClassPathResource("products.csv")); | |
reader.setLineMapper(new DefaultLineMapper<Product>() { | |
{ | |
setLineTokenizer(new DelimitedLineTokenizer() { | |
{ | |
setNames(new String[] { "id", "name", "price", "description" }); | |
} | |
}); | |
setFieldSetMapper(new BeanWrapperFieldSetMapper<Product>() { | |
{ | |
setTargetType(Product.class); | |
} | |
}); | |
} | |
}); | |
return reader; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment