how to launch Spring Batch Job using CommandLineJobRunner having Java configuration

前端 未结 1 1197
甜味超标
甜味超标 2021-01-21 22:37

I have my batch job definition in Java based configuration file. I have seen that CommandLineJobRunner can be used to launch job, but the job definition should be d

1条回答
  •  迷失自我
    2021-01-21 22:56

    The first argument of CommandLineJobRunner can be either:

    • The xml file containing the job definition
    • Or the fully qualified name of the configuration class containing the job definition

    Starting from Spring Batch v4, there is a toggle on the top of each documentation page that allows you to show examples in Java or Xml config. For example, when the toggle is set to "Java", the documentation section here: https://docs.spring.io/spring-batch/4.0.x/reference/html/job.html#runningJobsFromCommandLine shows how to use the CommandLineJobRunner with a Java configuration class:

    $>java -cp your/class/path org.springframework.batch.core.launch.support.CommandLineJobRunner io.spring.EndOfDayJobConfiguration endOfDay schedule.date(date)=2007/05/05
    

    io.spring.EndOfDayJobConfiguration is the fully qualified class name containing the endOfDay job definition.

    0 讨论(0)
提交回复
热议问题