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 Maven and Eclipse

  • Download the "no-dependencies" version of the distribution and unzip to create a directory spring-batch-<versionId>.
  • 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.

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 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).

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.