- Spring Batch Tutorial
- Spring Batch - Home
- Spring Batch - Overview
- Spring Batch - Environment
- Spring Batch - Architecture
- Spring Batch - Application
- Spring Batch - Configuration
- Readers, Writers & Processors
- Spring Batch - Basic Application
- Spring Batch - XML to MySQL
- Spring Batch - CSV to XML
- Spring Batch - MySQL to XML
- Spring Batch - MySQL to Flat File
- Spring Batch Useful Resources
- Spring Batch - Quick Guide
- Spring Batch - Useful Resources
- Spring Batch - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Spring Batch - Application
Almost all the examples in this tutorial contain the following files −
- Configuration file (XML file)
- Tasklet/processor (Java class)
- Java class with setters and getters (Java class (bean))
- Mapper class (Java class)
- Launcher class (Java class)
The configuration file (XML) contains the following −
The job and step definitions.
Beans defining readers and writers.
Definition of components like JobLauncher, JobRepository, Transaction Manager, and Data Source.
In our examples, for better understanding, we have divided this in to two files the job.xml file (defines job, step, reader and writer) and context.xml file (job launcher, job repository, transaction manager and data source).
The Mapper class, depending upon the reader, implements interfaces such as row mapper, field set mapper, etc. It contains the code to get the data from the reader and to set it to a Java class with setter and getter methods (Java Bean).
Java Bean Class
A Java class with setters and getters (Java bean) represents data with multiple values. It acts as a helper class. We will pass the data from one component (reader, writer, processer) to other in the form of object of this class.
The Tasklet/processor class contains the processing code of the Spring Batch application. A processor is a class which accepts an object that contains the data read, processes it, and returns the processed data (in the form object).
This class (App.java) contains the code to launch the Spring Batch application.