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. There is also a simple command line sample (or "archetype") which has a bare bones but complete implementation of a simpel job. The source code for the samples (and the other modules) is available either from the .Zip assembly or from Git.
Using SpringSource Tool Suite (STS)
This is the quickest way to get started. It requires an internet connection for download, and access to a Maven repository (remote or local).
- Download STS version 2.3.2.* from the SpringSource website. STS is a free Eclipse bundle with many features useful for Spring developers.
- Go to New->Other... and select SpringSource Tool Suite->Template Project from the wizard chooser.
- The wizard has a drop down with a list of template projects. One of them is a "Simple Spring Batch Project". Select it and follow the wizard.
- A project is created with all dependencies and a simple input/output job configuration. It can be run using a unit test, or on the command line (see instructions in the pom.xml).
Using the .Zip Distribution
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 "no-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 org.springframework.batch.samples project from the samples directory.
- Find all the compile scope and non-optional runtime jar files listed in the core dependencies report and infrastructure dependencies report, and import them into the project.
- 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 Git
- Check out the Spring Batch project from Git (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.
Using Gradle (for Groovy programmers)
- There is a Groovy project template with instructions available here