Getting Started with Spring Batch Admin

Easiest way to get started: deploy the sample. It's a regular war file. Once it's deployed, browse with a web browser (e.g. localhost:8080/spring-batch-admin-sample) and check out the features for launching jobs and inspecting job executions.

Ways to get the code:

  1. Use the Spring Community Download page.
  1. Check out the source code from Github. Github also has .zip downloads of the repository from tagged commits.
  2. Use Maven to download the artifacts by creating a pom with dependency

    For snapshots, add a repository location:

            <name>Spring Maven Snapshot Repository</name>

Add your Own Job Executions

Just execute a job (e.g. from command line) against the same database that is used by Spring Batch Admin, and the UI picks up the meta data from the usual Spring Batch tables.

Add your Own Jobs For Launching

Include Spring XML files in META-INF/spring/batch/jobs. Each file should be self-contained (except for Batch execution components like the jobRepository which are provided centrally), and carry one or more bean definitions for a Spring Batch Job. When the application starts these files are scanned and loaded as child contexts, and then the jobs are registered with a JobRegistry in the parent. Because they are child contexts you don't have to worry about name clashes between different XML files or different contributing JARs (except for the jobs which must have unique names, at present, but perhaps not when we get to a release).

As a convenience, the child contexts inherit property placeholders and AOP configuration from the parent (this is not the default behaviour for a child context). This means you can control those things centrally if you need to. Of course, the child can always create its own placeholder definition and AOP configuration, but these will not affect the parent or any of its siblings.

Environment Settings

The most likely thing you will want to customize is the location of the database. Spring Batch Admin ships with an embedded HSQLDB database, which is initialized on start up.

  • To change the database type add a file to the application classpath called batch-[type].properties, where [type] is the database type you want to use. Copy the contents of the from the Manager jar and change the values to suit your environment. Then launch the application with a system property -DENVIRONMENT=[type].
  • To stop the database from being wiped and re-created just set (in the properties file or as a System property).
  • To configure where input files are uploaded to, add the property batch.files.upload-dir=/sba/input to one of your batch configuration files. By default, the java temp directory is used System.getProperty(""). It's important to note that files are not permitted to be uploaded into any directory other than the one configured or a subdirectory of it.

Overriding Components from Spring Batch Admin

The system tries to provide some useful defaults for things like transaction manager, job repository, job registry etc. Most of these live in the manager jar in a special place: META-INF/spring/batch/bootstrap. If you want to override them, just add your own versions of the same bean definitions to a Spring XML config file in META-INF/spring/batch/override (these are guaranteed to load after the bootstrap files, so they can override default definitions). You could use this to override the data source definition as an alternative to the environment settings described above.

Create your own Web Application

Hints for custom applications:

  • Look at the sample.
  • Create a war project with an index.jsp and a web.xml (from the sample or from the spring-batch-admin-resources.jar).
  • Include the spring-batch-admin-*.jar files in WEB-INF/lib. In the sample this is done simply by making the WAR depend on those jar files in the Maven pom.
  • Deploy the web app.