Spring Batch – Series – 2 – JobRepository

Tram Ho

At this article I will create a JobRepository.

What is JobRepository?

1. Concepts.

  • CRUD in SQL:
    OperationSQL
    CreateINSERT
    ReadSELECT
    UpdateUPDATE
    DeleteDELETE
  • JobRepository

    Repository responsible for persistence of batch meta-data entities.

    The task of storing and putting the object information into the correct installation of Spring Batch.

    TableObject
    BATCH_JOB_INSTANCEJobInstance
    BATCH_JOB_EXECUTIONJobExecution
    BATCH_JOB_EXECUTION_PARAMSJobParameters
    BATCH_STEP_EXECUTIONStepExecution
    BATCH_JOB_EXECUTION_CONTEXTExecutionContext
    BATCH_STEP_EXECUTION_CONTEXTExecutionContext

2. Create a demo project.

Visit spring initializr to create a project

  • Add the necessary libraries to the project:

    Tables

  • Click:

    Tables

3. Install resource.

  • In the application.properties file, perform config initialization tables.

  • Create a MySQL database connection class config

  • Create config for jobRepository

  • Perform a run once we get a system tables group of Spring Batch

    Tables

4. Class Controller

  • Next create a class controller that sends a request url to execute creating a JobExecution

5. Check

  • Make a request “/ jobRepository”

    Tables

  • Check if Job with “jobName” is registered.

    Tables

  • Already signed the job’s params successfully.

    Tables

So has successfully registered a Job through the jobRepository class.

What’s wrong with everyone’s suggestions.

Share the news now

Source : Viblo