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vjEg+HIQPADAqMys4LcHPW+vd/eC7kSpX+RdmS/OqLw3UKfMUrBrbwU66Gdte4FN/X5tvaSPtMaweyeYe8VlYf28v/B6Oo7i+OaCG0ht3HOVS2+577UTx6Sx91rOy03ZsvTcDHvs+rovXXmcAdK/S62xxPcCAGgnsyn44MXfJxWNL7NUAu5cKC+IJCkP5JeIxbgjLculZfuKBF95776rmyCMKxSiJL5h43PHmrBPLXXTn76vP+bSMdl7ubqmLL53OP7yx6778o/Lx5kh/bvUGot/LwCA9tIpwdfHvuAHotBIsvCvCeUFOcTyseeBGC3BtWH3TqleeTAn8r0MQ8aX9ZsnnNnqa/FzVjam+F5V58Meu65r+x06Tkvlv0vVuXcvAIAW0znBv+Ntl4qRSSWSS2uYaITy/RK8uY8nsuC+UdtxBS+2cei2/nOVUDmm+F5V50Meu6lr+x06TsvYY/HuBQDQYmZT8MmL/yB7BfdFkh5nS7cJ4efPgogqRaLr++Lw29p7RYIvvXcktupxxfdaVgMziFHGp2+Zi84t0Zv7unFUjim+V9X5kMdu6vrHJeM0/xa2TwQPADPOzM7gzRfFElGYZLawokyEkS//+i/2sUgTagten+q6rt/kuvQluyH3dmW9pF5+X921FmJS5voL7jXO+PLHaZ6raJzpc1Y1piqJavzzYY9d1/XOS8aZXrd9muNxxhLdCwCgpcz4En2MFc1+vbrXXW7uPPv8vAMAzACdFPxzzz2XpTmC133Hs1Lv8+uZBsEDAEya1gl+GE7oceoxZdFES8vI3YHgAQAmTecEDwAAAAgeAACgkyB4AACADoLgAQAAOgiCBwAA6BxK/X8vfOsxG+IBCAAAAABJRU5ErkJggg==" alt="" />

2、文件说明:

2.1、CreditBill:表示信用卡消费记录领域对象

2.2、CreditBillProcessor:记录处理类,本场景仅打印信息

2.3、credit-card-bill-201910.csv:原始账单数据

2.4、job.xml:作业定义文件

2.5、job-context.xml :Spring Batch 批处理任务需要的基础信息

2.6、JobLaunch:调用批处理作业类

2.7、JobLaunchTest:Junit单元测试类,使用Spring提供的测试框架类。

2.8、pom.xml:引用相关jar包

3、文件内容:

3.1、CreditBill:实体类对象

/**
* @author miaosj
* @version 1.0
* @date 2019/10/8
*/
public class CreditBill {
/**
* 银行账户
*/
private String accountID;
/**
* 账户名
*/
private String name;
/**
* 消费金额
*/
private double amount;
/**
* 消费日期
*/
private String date;
/**
* 消费场所
*/
private String address; public String getAccountID() {
return accountID;
} public void setAccountID(String accountID) {
this.accountID = accountID;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public double getAmount() {
return amount;
} public void setAmount(double amount) {
this.amount = amount;
} public String getDate() {
return date;
} public void setDate(String date) {
this.date = date;
} public String getAddress() {
return address;
} public void setAddress(String address) {
this.address = address;
}
}

3.2、credit-card-bill-201910.csv:原始账单数据

,tom,100.00,-- ::,Lu Jia Zui road
,tom,320.00,-- ::,Lu Jia Zui road
,tom,674.00,-- ::,Lu Jia road
,tom,793.00,-- ::,Lu Jia Zui road
,tom,360.00,-- ::,Lu Jia Zui road
,tom,893.00,-- ::,Lu Jia Zui road

3.3、job-context.xml:job基础设施

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
default-autowire="byName">
<!--定义作业仓库SpringBatch提供了两种作业仓库来记录job执行期产生的信息:一种是内存,另一种是数据库,此处采用内存-->
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
</bean>
<!--定义作业调度器,用来启动Job -->
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository"/>
</bean>
<!--事务管理器,用于springbatch框架在对数据操作过程中体统事务能力-->
<bean id="transactionManager"
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager"/>
</beans>

3.4、job.xml:定义job

<?xml version="1.0" encoding="UTF-8"?>
<bean:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:bean="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.2.xsd">
<!--引入job-context.xml配置文件-->
<bean:import resource="classpath:job-context.xml"/>
<!--定义billJob billStep 包含读数据 处理数据 写数据-->
<job id="billJob">
<step id="billStep">
<tasklet transaction-manager="transactionManager">
<!--commit-interval="2" 表示任务提交间隔的大小 此处表示每处理2条数据 进行一次写入操作-->
<chunk reader="csvItemReader" writer="csvItemWriter" processor="creditBillProcessor" commit-interval="2">
</chunk>
</tasklet>
</step>
</job> <!-- 读取信用卡账单文件,CSV格式 -->
<bean:bean id="csvItemReader"
class="org.springframework.batch.item.file.FlatFileItemReader"
scope="step">
<!--设置读取的文件资源-->
<bean:property name="resource"
value="classpath:data/credit-card-bill-201910.csv"/>
<!--将文本中的每行记录转换为领域对象-->
<bean:property name="lineMapper">
<bean:bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<!--引用lineTokenizer-->
<bean:property name="lineTokenizer" ref="lineTokenizer"/>
<!--fieldSetMapper根据lineTokenizer中定义的names属性映射到领域对象中去-->
<bean:property name="fieldSetMapper">
<bean:bean class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
<bean:property name="prototypeBeanName" value="creditBill">
</bean:property>
</bean:bean>
</bean:property>
</bean:bean>
</bean:property>
</bean:bean>
<!-- lineTokenizer 定义文本中每行的分隔符号 以及每行映射成FieldSet对象后的name列表 -->
<bean:bean id="lineTokenizer"
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<bean:property name="delimiter" value=","/>
<bean:property name="names">
<bean:list>
<bean:value>accountID</bean:value>
<bean:value>name</bean:value>
<bean:value>amount</bean:value>
<bean:value>date</bean:value>
<bean:value>address</bean:value>
</bean:list>
</bean:property>
</bean:bean> <!-- 写信用卡账单文件,CSV格式 -->
<bean:bean id="csvItemWriter"
class="org.springframework.batch.item.file.FlatFileItemWriter"
scope="step">
<!--<bean:property name="resource" value="file:target/data/outputFile.csv"/>-->
<!--<bean:property name="resource" value="file:target/outputFile.csv"/>-->
<bean:property name="resource" value="classpath:data/outputFile.csv"/>
<bean:property name="lineAggregator">
<bean:bean
class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
<bean:property name="delimiter" value=","></bean:property>
<bean:property name="fieldExtractor">
<bean:bean
class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
<bean:property name="names" value="accountID,name,amount,date,address">
</bean:property>
</bean:bean>
</bean:property>
</bean:bean>
</bean:property>
</bean:bean>
<!--领域对象 并标注为原型-->
<bean:bean id="creditBill" scope="prototype"
class="CreditBill">
</bean:bean>
<!--负责业务数据的处理-->
<bean:bean id="creditBillProcessor" scope="step"
class="CreditBillProcessor">
</bean:bean>
</bean:beans>

3.5、JobLaunch:java调用

import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; /**
* @author E101206
* @version 1.0
* @date 2019/10/8
*/
public class JobLaunch {
@SuppressWarnings("resource")
public static void main(String[] args) {
//初始化应用上下文
ApplicationContext context = new ClassPathXmlApplicationContext("job/job.xml");
//获取作业调度,根据Bean的名称从Spring的上下文获取
JobLauncher launcher = (JobLauncher) context.getBean("jobLauncher");
//获取任务对象
Job job = (Job) context.getBean("billJob");
try {
JobExecution result = launcher.run(job, new JobParameters());
System.out.println(result.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}

3.6、JobLaunchTest:单位测试

/**
* @author E101206
* @version 1.0
* @date 2019/10/8
*/
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"/job/job.xml"})
public class JobLaunchTest {
@Autowired
private JobLauncher jobLauncher; @Autowired@Qualifier("billJob")
private Job job; @Before
public void setUp() throws Exception {
} @After
public void tearDown() throws Exception {
} @Test
public void billJob() throws Exception {
JobExecution result = jobLauncher.run(job, new JobParameters());
System.out.println(result.toString());
}
}

3.7、pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.msj</groupId>
<artifactId>spring-batch-example</artifactId>
<version>1.0-SNAPSHOT</version> <properties>
<jdk.version>1.8</jdk.version>
<spring.version>4.3.8.RELEASE</spring.version>
<spring.batch.version>3.0.7.RELEASE</spring.batch.version>
<junit.version>4.11</junit.version>
</properties> <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!--&lt;!&ndash; Spring Core &ndash;&gt;-->
<!--<dependency>-->
<!--<groupId>org.springframework</groupId>-->
<!--<artifactId>spring-core</artifactId>-->
<!--<version>${spring.version}</version>-->
<!--</dependency>--> <!--&lt;!&ndash; Spring jdbc, for database &ndash;&gt;-->
<!--<dependency>-->
<!--<groupId>org.springframework</groupId>-->
<!--<artifactId>spring-jdbc</artifactId>-->
<!--<version>${spring.version}</version>-->
<!--</dependency>--> <!--&lt;!&ndash; Spring XML to/back object &ndash;&gt;-->
<!--<dependency>-->
<!--<groupId>org.springframework</groupId>-->
<!--<artifactId>spring-oxm</artifactId>-->
<!--<version>${spring.version}</version>-->
<!--</dependency>--> <!-- Spring Batch dependencies -->
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
<version>${spring.batch.version}</version>
</dependency> <!--<dependency>-->
<!--<groupId>org.springframework.batch</groupId>-->
<!--<artifactId>spring-batch-infrastructure</artifactId>-->
<!--<version>${spring.batch.version}</version>-->
<!--</dependency>--> <!-- Spring Batch unit test -->
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
<version>${spring.batch.version}</version>
</dependency> <!-- Junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency> </dependencies>
</project>

4、概念

4.1、Job Repository:作业仓库,负责job、step执行过程中的状态保存

4.2、Job launcher:作业调度器,提供执行job的入口

4.3、Job:作业,由多个step组成,封装整个批处理操作

4.4、Step:作业步,job的一个执行环节

4.5、Tasklet:Step中具体执行逻辑的操作,可以重复执行,可以设置具体的同步、异步操作

4.6、Chunk:给定数量的Item的集合,可以定义对Chunk读操作、处理操作、写操作,提交间隔等

4.7、Item:一条记录

4.8、ItemReader:从数据源读取Item

4.9、ItemProcessor:在Item写入数据源之前,对数据进行处理如:数据清洗,数据转换,数据过滤、数据校验等

4.10、ItemWriter:将Item批量写入数据源

SpringBatch批处理框架:入门项目的更多相关文章

  1. SpringBatch批处理框架

    1.前言:本博客是对于刘相SpringBatch批处理框架的学习 1.1.参考网站:https://docs.spring.io/spring-batch/4.2.x/reference/html/i ...

  2. spring-batch批处理框架

    转自 http://www.cnblogs.com/gulvzhe/archive/2011/10/21/2220260.html 这个框架没有实际操作,只是从同事处学习到,先转个好文章,以后有机会再 ...

  3. 通过例子讲解Spring Batch入门,优秀的批处理框架

    1 前言 欢迎访问南瓜慢说 www.pkslow.com获取更多精彩文章! Spring相关文章:Springboot-Cloud相关 Spring Batch是一个轻量级的.完善的批处理框架,作为S ...

  4. ThinkJS框架入门详细教程(二)新手入门项目

    一.准备工作 参考前一篇:ThinkJS框架入门详细教程(一)开发环境 安装thinkJS命令 npm install -g think-cli 监测是否安装成功 thinkjs -v 二.创建项目 ...

  5. SpringMVC框架入门配置 IDEA下搭建Maven项目(zz)

    SpringMVC框架入门配置 IDEA下搭建Maven项目 这个不错哦 http://www.cnblogs.com/qixiaoyizhan/p/5819392.html

  6. Newbe.Claptrap 框架入门,第二步 —— 创建项目

    接上一篇 Newbe.Claptrap 框架入门,第一步 -- 开发环境准备 ,我们继续了解如何创建一个 Newbe.Claptrap 项目. Newbe.Claptrap 是一个用于轻松应对并发问题 ...

  7. Taurus.MVC 微服务框架 入门开发教程:项目部署:1、微服务应用程序常规部署实现多开,节点扩容。

    系列目录: 本系列分为项目集成.项目部署.架构演进三个方向,后续会根据情况调整文章目录. 本系列第一篇:Taurus.MVC V3.0.3 微服务开源框架发布:让.NET 架构在大并发的演进过程更简单 ...

  8. Taurus.MVC 微服务框架 入门开发教程:项目部署:2、让Kestrel支持绑定多个域名转发,替代Ngnix使用。

    系列目录: 本系列分为项目集成.项目部署.架构演进三个方向,后续会根据情况调整文章目录. 本系列第一篇:Taurus.MVC V3.0.3 微服务开源框架发布:让.NET 架构在大并发的演进过程更简单 ...

  9. Taurus.MVC 微服务框架 入门开发教程:项目部署:3、微服务应用程序版本升级:全站升级和局部模块升级。

    系列目录: 本系列分为项目集成.项目部署.架构演进三个方向,后续会根据情况调整文章目录. 本系列第一篇:Taurus.MVC V3.0.3 微服务开源框架发布:让.NET 架构在大并发的演进过程更简单 ...

随机推荐

  1. springboot启动方式

    第一种(本地开发使用)在项目的根目录下有一个带有main函数的Application类,可以直接执行这个main函数.(使用的是SpringBoot内置的tomcat) 第二种(本地开发使用)在pom ...

  2. 2018-2-13-win10-uwp-让焦点在点击在页面空白处时回到textbox中

    title author date CreateTime categories win10 uwp 让焦点在点击在页面空白处时回到textbox中 lindexi 2018-2-13 17:23:3 ...

  3. 深度探索C++对象模型读书笔记-第六章执行期语意学

    在函数中,编译器会帮助将析构函数(Destructor) 安插在相应的位置.对于函数中的局部对象,会将析构函数安插在对象的每一个离开点. 例如: 1: void Function(int a) { 2 ...

  4. Cacti 添加 CPU 监听

    Cacti版本: 0.8.8a 將 http://forums.cacti.net/about29832-0-asc-135.html 网址的template下载,有1,2,4,8,12,16核心的t ...

  5. Mybatis3中@SelectProvider传递参数

    一.通常情况下我们使用实体类或者vo类来传递参数,这样可以在provider中直接使用#{param}来获取参数 二.在mybatis3.3以下版本只能传递一个参数,所以如果要传递多个参数必须封装成M ...

  6. JUC 一 FutureTask

    java.util.concurrent public class FutureTask<V> implements RunnableFuture<V> 简介 FutureTa ...

  7. selenium 无头浏览器headless browser

    无头浏览器,即没有界面的浏览器,浏览器该有的功能特性都有. if browser.lower() == "chrome": # 无头浏览器 chrome_opt = webdriv ...

  8. 牛客多校第八场 G Gemstones 栈/贪心

    题意: 对于一个序列,把可以把连着三个相同的字母拿走,问最多拿走多少组. 题解: 直接模拟栈,三个栈顶元素相同则答案+1,并弹出栈 #include<bits/stdc++.h> usin ...

  9. topjui.core.js

    var defaultConfig = { pageLoadComplete: false, config: { ctx: "", mainPage: false, pkName: ...

  10. java: java中的 getInstance() 的理解

    原文地址:https://blog.csdn.net/qq_26293573/article/details/78184844 在单例模式下使用 . 单例模式:所谓单例模式就是一个类有且只有一个实例, ...