Spring batch – Quick start

TODO: Batch process introduction

TODO: Spring batch architecture introduction

Project Initialization

Spring batch can be initialized with Spring intializr.


One of the essential dependencies of spring batch is Spring data-jpa, as it needs to store and maintain the metadata information of the Job and step execution history.


The main SpringBootApplication class may look similar as shown below. Run it and ensure that the context is loading properly without any issues.

package com.kesavan.springbatchexp;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class SpringbatchexpApplication {
	public static void main(String[] args) {
	      SpringApplication.run(SpringbatchexpApplication.class, args);

Step-1 : Adding a scheduler to the application.

For our understanding purpose, let us use a Scheduler to launch the jobs. In this step, let’s just introduce a scheduler that runs every second.

The following annotations can be used to configure a scheduler.

  1. @EnableScheduling – to your SpringBootApplication class
  2. @Scheduled – to the method in your scheduler class
    • A scheduler class needs to be created – Annotated with @Component annotation
package com.kesavan.springbatchexp.job;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

public class DataSummarizerJobScheduler {

    @Scheduled(fixedRate = 1000)
    public void launchJob() {
        System.out.println("Scheduler runs now : "+System.currentTimeMillis());






Leave a Reply

Your email address will not be published. Required fields are marked *