Class JobLauncherApplicationRunner

java.lang.Object
org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.InitializingBean, org.springframework.boot.ApplicationRunner, org.springframework.context.ApplicationEventPublisherAware, org.springframework.core.Ordered

public class JobLauncherApplicationRunner extends Object implements org.springframework.boot.ApplicationRunner, org.springframework.beans.factory.InitializingBean, org.springframework.core.Ordered, org.springframework.context.ApplicationEventPublisherAware
ApplicationRunner to launch Spring Batch jobs. If a single job is found in the context, it will be executed by default. If multiple jobs are found, launch a specific job by providing a jobName.
Since:
2.3.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default order for the command line runner.

    Fields inherited from interface org.springframework.core.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
    JobLauncherApplicationRunner(org.springframework.batch.core.launch.JobLauncher jobLauncher, org.springframework.batch.core.explore.JobExplorer jobExplorer, org.springframework.batch.core.repository.JobRepository jobRepository)
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    protected void
    execute(org.springframework.batch.core.Job job, org.springframework.batch.core.JobParameters jobParameters)
     
    int
     
    protected void
     
    void
    run(String... args)
     
    void
    run(org.springframework.boot.ApplicationArguments args)
     
    void
    setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher publisher)
     
    void
    setJobName(String jobName)
     
    void
    setJobParametersConverter(org.springframework.batch.core.converter.JobParametersConverter converter)
     
    void
    setJobRegistry(org.springframework.batch.core.configuration.JobRegistry jobRegistry)
     
    void
    setJobs(Collection<org.springframework.batch.core.Job> jobs)
     
    void
    setOrder(int order)
     
    void
    Deprecated, for removal: This API element is subject to removal in a future version.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_ORDER

      public static final int DEFAULT_ORDER
      The default order for the command line runner.
      See Also:
  • Constructor Details

    • JobLauncherApplicationRunner

      public JobLauncherApplicationRunner(org.springframework.batch.core.launch.JobLauncher jobLauncher, org.springframework.batch.core.explore.JobExplorer jobExplorer, org.springframework.batch.core.repository.JobRepository jobRepository)
      Parameters:
      jobLauncher - to launch jobs
      jobExplorer - to check the job repository for previous executions
      jobRepository - to check if a job instance exists with the given parameters when running a job
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • validate

      @Deprecated(since="3.0.10", forRemoval=true) public void validate()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setOrder

      public void setOrder(int order)
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface org.springframework.core.Ordered
    • setApplicationEventPublisher

      public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher publisher)
      Specified by:
      setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAware
    • setJobRegistry

      @Autowired(required=false) public void setJobRegistry(org.springframework.batch.core.configuration.JobRegistry jobRegistry)
    • setJobName

      public void setJobName(String jobName)
    • setJobParametersConverter

      @Autowired(required=false) public void setJobParametersConverter(org.springframework.batch.core.converter.JobParametersConverter converter)
    • setJobs

      @Autowired(required=false) public void setJobs(Collection<org.springframework.batch.core.Job> jobs)
    • run

      public void run(org.springframework.boot.ApplicationArguments args) throws Exception
      Specified by:
      run in interface org.springframework.boot.ApplicationRunner
      Throws:
      Exception
    • run

      public void run(String... args) throws org.springframework.batch.core.JobExecutionException
      Throws:
      org.springframework.batch.core.JobExecutionException
    • launchJobFromProperties

      protected void launchJobFromProperties(Properties properties) throws org.springframework.batch.core.JobExecutionException
      Throws:
      org.springframework.batch.core.JobExecutionException
    • execute

      protected void execute(org.springframework.batch.core.Job job, org.springframework.batch.core.JobParameters jobParameters) throws org.springframework.batch.core.repository.JobExecutionAlreadyRunningException, org.springframework.batch.core.repository.JobRestartException, org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException, org.springframework.batch.core.JobParametersInvalidException
      Throws:
      org.springframework.batch.core.repository.JobExecutionAlreadyRunningException
      org.springframework.batch.core.repository.JobRestartException
      org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException
      org.springframework.batch.core.JobParametersInvalidException