public class TaskJobLauncherCommandLineRunner
extends org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner
CommandLineRunner
to launch
Spring Batch jobs. Runs all
jobs in the surrounding context by default and throws an exception upon the first job
that returns an BatchStatus
of FAILED if a TaskExecutor
in the
JobLauncher
is not specified. If a TaskExecutor
is specified
in the JobLauncher
then all Jobs are launched and an
exception is thrown if one or more of the jobs has an BatchStatus
of FAILED.
TaskJobLauncherCommandLineRunner can also be used to launch a specific job by
providing a jobName. The TaskJobLaunchercommandLineRunner takes the place of the
JobLauncherCommandLineRunner
when
it is in use.Constructor and Description |
---|
TaskJobLauncherCommandLineRunner(org.springframework.batch.core.launch.JobLauncher jobLauncher,
org.springframework.batch.core.explore.JobExplorer jobExplorer,
org.springframework.batch.core.repository.JobRepository jobRepository,
TaskBatchProperties taskBatchProperties)
Create a new
TaskJobLauncherCommandLineRunner . |
Modifier and Type | Method and Description |
---|---|
protected void |
execute(org.springframework.batch.core.Job job,
org.springframework.batch.core.JobParameters jobParameters) |
void |
run(String... args) |
void |
setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher publisher) |
public TaskJobLauncherCommandLineRunner(org.springframework.batch.core.launch.JobLauncher jobLauncher, org.springframework.batch.core.explore.JobExplorer jobExplorer, org.springframework.batch.core.repository.JobRepository jobRepository, TaskBatchProperties taskBatchProperties)
TaskJobLauncherCommandLineRunner
.jobLauncher
- to launch jobsjobExplorer
- to check the job repository for previous executionsjobRepository
- to check if a job instance exists with the given parameters
when running a jobtaskBatchProperties
- the properties used to configure the taskBatchProperties.public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher publisher)
setApplicationEventPublisher
in interface org.springframework.context.ApplicationEventPublisherAware
setApplicationEventPublisher
in class org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner
public void run(String... args) throws org.springframework.batch.core.JobExecutionException
run
in interface org.springframework.boot.CommandLineRunner
run
in class org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner
org.springframework.batch.core.JobExecutionException
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
execute
in class org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner
org.springframework.batch.core.repository.JobExecutionAlreadyRunningException
org.springframework.batch.core.repository.JobRestartException
org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException
org.springframework.batch.core.JobParametersInvalidException
Copyright © 2019 Pivotal Software, Inc.. All rights reserved.