Spring Batch Getting Started

A convenient way to get started quickly with Spring Batch is to run the samples which are packaged in the samples module. The source code for the samples (and the other modules) is available either from the .Zip assembly or from Subversion.

Using the .Zip Distribution

With Eclipse and without Maven

Similar instructions would apply to other IDEs.

  • Download the "with-dependencies" package and unzip to create a directory spring-batch-<versionId>.
  • Open Eclipse and make a workspace in the directory you just created.
  • Import the samples project from the samples directory.
  • Add all the jar files in the distribution as library dependencies (except spring-batch-samples-<versionId>.jar). There are jars in samples/lib and in sources/lib, including some duplicates.
  • Force the workspace to build (e.g. Project -> Clean...)
  • Run the unit tests in your project under src/test/java. N.B. the FootbalJobFunctionTests takes quite a long time to run.

You can get a pretty good idea about how to set up a job by examining the unit tests in the org.springframework.batch.sample package (in src/main/java) and the configuration in src/main/resources/jobs.

To launch a job from the command line instead of a unit test use the CommandLineJobRunner.main() method (see Javadocs included in that class).

With Maven on the Command Line

  • Download the distribution as above.
  • Then run Maven in the spring-batch-samples directory, e.g.
    $ cd spring-batch-samples
    $ mvn test

With Maven and Eclipse

  • Download the distribution as above.
  • Get the Q4E Eclipse-plugin (http://q4e.googlecode.com/svn/trunk/updatesite). If you can't or don't want to install this plugin, you can use the Maven Eclipse Plugin to create the classpath entries you need.
  • Open Eclipse and create a workspace as for the non-Mavenized version.
  • Import the samples project as above.
  • The project should build cleanly without having to fix the dependencies. If it doesn't, make sure you are online, and maybe try building on the command line first to make sure all the dependencies are downloaded. See the building instructions if you run into difficulty.

Using Maven and Subversion

  • Check out the Spring Batch project from Subversion (instructions are available here).
  • Run Maven from the command line in the samples directory. There are additional building instructions and suggestions about what to do if it goes wrong here.

The Original m3 Distribution

The original "m3" release had some issues like missing dependencies, so if you are using that either get the newer release, or see below. (The m3a release is just an update of the .Zip packages - there is no corresponding update of the jar files, which did not change.)

If you are using not using Maven you will need some dependencies that were missing from the distro, so get these jar files from somewhere else:

  • Servlet API (2.3 or better)
  • spring-test-2.5.jar
  • spring-web-2.5.jar
  • easymock.jar (1.1 or 1.2)
  • commons-io (1.3.1)
  • xmlunit (1.1)
  • aspectjweaver (1.5.3)
  • hsqldb (

If you are using Maven get the parent project pom by downloading it from Subversion (export from here):

$ cd samples
$ svn export https://springframework.svn.sourceforge.net/svnroot/springframework/spring-batch/tags/spring-batch-1.0.0.m3/parent parent