public class JobLauncherApplicationRunner
extends java.lang.Object
implements org.springframework.boot.ApplicationRunner, org.springframework.core.Ordered, org.springframework.context.ApplicationEventPublisherAware
ApplicationRunner to launch Spring Batch jobs. Runs all
jobs in the surrounding context by default. Can also be used to launch a specific job
by providing a jobName| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_ORDER
The default order for the command line runner.
|
| Constructor and Description |
|---|
JobLauncherApplicationRunner(org.springframework.batch.core.launch.JobLauncher jobLauncher,
org.springframework.batch.core.explore.JobExplorer jobExplorer,
org.springframework.batch.core.repository.JobRepository jobRepository)
Create a new
JobLauncherApplicationRunner. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
execute(org.springframework.batch.core.Job job,
org.springframework.batch.core.JobParameters jobParameters) |
int |
getOrder() |
protected void |
launchJobFromProperties(java.util.Properties properties) |
void |
run(org.springframework.boot.ApplicationArguments args) |
void |
run(java.lang.String... args) |
void |
setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher publisher) |
void |
setJobNames(java.lang.String jobNames) |
void |
setJobParametersConverter(org.springframework.batch.core.converter.JobParametersConverter converter) |
void |
setJobRegistry(org.springframework.batch.core.configuration.JobRegistry jobRegistry) |
void |
setJobs(java.util.Collection<org.springframework.batch.core.Job> jobs) |
void |
setOrder(int order) |
public static final int DEFAULT_ORDER
public JobLauncherApplicationRunner(org.springframework.batch.core.launch.JobLauncher jobLauncher,
org.springframework.batch.core.explore.JobExplorer jobExplorer,
org.springframework.batch.core.repository.JobRepository jobRepository)
JobLauncherApplicationRunner.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 jobpublic void setOrder(int order)
public int getOrder()
getOrder in interface org.springframework.core.Orderedpublic void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher publisher)
setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAware@Autowired(required=false) public void setJobRegistry(org.springframework.batch.core.configuration.JobRegistry jobRegistry)
public void setJobNames(java.lang.String jobNames)
@Autowired(required=false) public void setJobParametersConverter(org.springframework.batch.core.converter.JobParametersConverter converter)
@Autowired(required=false) public void setJobs(java.util.Collection<org.springframework.batch.core.Job> jobs)
public void run(org.springframework.boot.ApplicationArguments args)
throws java.lang.Exception
run in interface org.springframework.boot.ApplicationRunnerjava.lang.Exceptionpublic void run(java.lang.String... args)
throws org.springframework.batch.core.JobExecutionException
org.springframework.batch.core.JobExecutionExceptionprotected void launchJobFromProperties(java.util.Properties properties)
throws org.springframework.batch.core.JobExecutionException
org.springframework.batch.core.JobExecutionExceptionprotected 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,
org.springframework.batch.core.launch.JobParametersNotFoundException
org.springframework.batch.core.repository.JobExecutionAlreadyRunningExceptionorg.springframework.batch.core.repository.JobRestartExceptionorg.springframework.batch.core.repository.JobInstanceAlreadyCompleteExceptionorg.springframework.batch.core.JobParametersInvalidExceptionorg.springframework.batch.core.launch.JobParametersNotFoundException