Up to this point, you've looked at why you'd use Spring Batch and examined the components of the
framework. However, looking at diagrams and learning new lingo will only take you so far. At some
point, you need to dig into the code: so, grab an editor, and let's start digging.
In this section, you build your first batch job. You walk through the setup of a Spring Batch project,
including obtaining the required files from Spring. You then configure a job and code the “Hello, World!”
version of Spring Batch. Finally, you learn how to launch a batch job from the command line.
Obtaining Spring Batch
Before you begin writing batch processes, you need to obtain the Spring Batch framework. There are
three options for doing this: using the SpringSource Tool Suite (STS), downloading the zip distribution,
or using Maven and Git.
Using the SpringSource Tool Suite
SpringSource (the maintainers of the Spring Framework and all of its derivatives) has put together an
Eclipse distribution with a collection of plug-ins designed specifically for Spring development. Features
include wizards for creating Spring projects, XML files and beans, the ability to deploy applications
remotely, and OSGi management. You can download this from the SpringSource web site.
Downloading the Zip Distribution
The Spring Batch framework is also available via download from the SpringSource web site as a zip file
with two options: all dependencies or no dependencies (as indicated by -no-dependencies in the file
name). Given that the project is set up for Maven use (although a build.xml file is included for those who
use Ant), the no-dependencies option is a better bet to download.
The zip file contains two directories: dist and samples. dist contains the release jar files: two for core,
two for infrastructure, and two for test (a source and compiled for each). In the samples directory, you
find a samples project (spring-batch-samples) that contains all the sample batch jobs you saw earlier in
this chapter, a project shell (spring-batch-simple-cli) that can be used to as a starting point for any
Spring Batch project, and a Maven parent project for the two. This template project is the easiest way for
you to get started with Spring Batch and will be the way you build our projects going forward.
Checking Out from Git
The final way to obtain the code for Spring Batch is to obtain it from the source code repository
SpringSource uses, Github. The Git version control system is a distributed version control system that
allows you to work with a full copy of the repository locally..
Listing 2-1. Checking Out the Project from Github
$ git clone git://github.com/SpringSource/spring-batch.git
This command exports the source code for the Spring Batch project including a shell for a project,
sample applications and all of the Spring Batch framework's source code. The command in Listing 2-1