In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Summary of Spring-Batch Learning (3)-- how to enter data
I. Overview of ItemReader
1.ItemReader: the interface that provides data
two。 There is only one method read () in this interface, which reads one data and moves to the next, and must return a null at the end of the reading, otherwise it indicates that the data has not finished reading.
Example:
OverViewApplication:
Package com.dhcc.batch.batchDemo.input.overview;import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication@EnableBatchProcessingpublic class OverViewApplication {public static void main (String [] args) {SpringApplication.run (OverViewApplication.class, args);}}
InputOverViewDemoJobConfiguration:
Package com.dhcc.batch.batchDemo.input.overview;import java.util.Arrays;import java.util.List;import org.springframework.batch.core.Job;import org.springframework.batch.core.Step;import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;import org.springframework.batch.item.ItemWriter;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration @ Configurationpublic class InputOverViewDemoJobConfiguration {@ Autowired private JobBuilderFactory jobBuilderFactory; @ Autowired private StepBuilderFactory stepBuilderFactory; @ Bean public Job inputOverViewDemoJob () {return jobBuilderFactory.get ("inputOverViewDemoJob") .start (inputOverViewDemoJobStep ()). Build ();} public Step inputOverViewDemoJobStep () {return stepBuilderFactory.get ("inputOverViewDemoJobStep"). Chunk (2) .reader (inputOverViewDemoReader ()) .writer (outputOverViewDemoWriter ()). Build () } private ItemWriter 4.0.0 com.dhcc.batch batchDemo 0.0.1-SNAPSHOT jar batchDemo Demo project for Spring Boot org.springframework.boot spring-boot-starter-parent 2.0.4.RELEASE UTF-8 UTF-8 1.8 org.springframework.boot spring -boot-starter-batch org.springframework.boot spring-boot-starter-test test org.springframework.batch spring-batch-test test org.springframework spring-oxm 5.0.8.RELEASE Com.thoughtworks.xstream xstream 1.4.10 org.springframework.boot spring-boot-starter-jdbc mysql mysql-connector-java runtime Org.springframework.boot spring-boot-maven-plugin
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.