Skip to content
tobiasflohre edited this page May 12, 2014 · 9 revisions
  1. Create a Spring Boot maven project. Take a look at this example, it's pretty much just using spring-boot-starter-parent as a parent und adding the Spring Boot build plugin. Then add the dependency to spring-boot-starter-batch-web like in the example. Current version on Maven Central is 1.0.0.RELEASE.
  2. If you have a database with the Spring Batch meta data tables and your business data, add the connection properties to the application.properties like in this example. If you don't specify these properties you'll get an in-memory database for the Spring Batch meta data tables.
  3. Add a simple logback.xml for logging. Here's an example inheriting from our basic log configuration to support log file separation.
  4. Add a batch job. You may define it in XML and put it into META-INF/spring/batch/jobs (overridable via property batch.config.path.xml) or in JavaConfig and put it into the package spring.batch.jobs (overridable via property batch.config.package.javaconfig). Each XML file or class annotated with @Configuration in the specified locations will get its own child ApplicationContext.
  5. Add an entry point to the application, a class with a main method invoking SpringApplication.run(...). Take a look at this example.
  6. Build the application via maven package. Then start the application using java -jar xxx.jar.

Default port is 8080. Take a look at the JavaDoc of these controllers to get to know the endpoints for starting jobs etc.: JobOperationsController and JobMonitoringController.

Clone this wiki locally