Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Spring-batch (ItemWriter) data is written to database, ordinary file, xml file, multi-file classification write.

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Summary of Spring-batch Learning (4)

I. introduction to ItemWriter

1. For read, it is a circular read in units of item, while for writer, it is written in blocks in units of chunk.

two。 Example (let's give a small example to understand its writer principle):

Code:

OutOverViewApplication

Package com.dhcc.batch.batchDemo.output.outview;import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication@EnableBatchProcessingpublic class OutOverViewApplication {public static void main (String [] args) {SpringApplication.run (OutOverViewApplication.class, args);}}

OutputViewItemWriterConfiguration

Package com.dhcc.batch.batchDemo.output.outview;import java.util.ArrayList;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.core.configuration.annotation.StepScope;import org.springframework.batch.item.ItemWriter;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Qualifier Import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configurationpublic class OutputViewItemWriterConfiguration {@ Autowired private JobBuilderFactory jobBuilderFactory; @ Autowired private StepBuilderFactory stepBuilderFactory; @ Autowired @ Qualifier ("OutputViewItemWriter") private ItemWriter

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report