Class JobLauncherApplicationRunner
java.lang.Object
org.springframework.boot.batch.autoconfigure.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:
- 4.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default order for the command line runner.Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionJobLauncherApplicationRunner(org.springframework.batch.core.launch.JobOperator jobOperator) Create a newJobLauncherApplicationRunner. -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidexecute(org.springframework.batch.core.job.Job job, org.springframework.batch.core.job.parameters.JobParameters jobParameters) intgetOrder()protected voidlaunchJobFromProperties(Properties properties) voidvoidrun(org.springframework.boot.ApplicationArguments args) voidsetApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher publisher) voidsetJobName(String jobName) voidsetJobParametersConverter(org.springframework.batch.core.converter.JobParametersConverter converter) voidsetJobRegistry(org.springframework.batch.core.configuration.JobRegistry jobRegistry) voidsetJobs(Collection<org.springframework.batch.core.job.Job> jobs) voidsetOrder(int order)
-
Field Details
-
DEFAULT_ORDER
public static final int DEFAULT_ORDERThe default order for the command line runner.- See Also:
-
-
Constructor Details
-
JobLauncherApplicationRunner
public JobLauncherApplicationRunner(org.springframework.batch.core.launch.JobOperator jobOperator) Create a newJobLauncherApplicationRunner.- Parameters:
jobOperator- to launch jobs
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
setOrder
public void setOrder(int order) -
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-
setApplicationEventPublisher
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher publisher) - Specified by:
setApplicationEventPublisherin interfaceorg.springframework.context.ApplicationEventPublisherAware
-
setJobRegistry
@Autowired(required=false) public void setJobRegistry(org.springframework.batch.core.configuration.JobRegistry jobRegistry) -
setJobName
-
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.Job> jobs) -
run
-
run
- Throws:
org.springframework.batch.core.job.JobExecutionException
-
launchJobFromProperties
protected void launchJobFromProperties(Properties properties) throws org.springframework.batch.core.job.JobExecutionException - Throws:
org.springframework.batch.core.job.JobExecutionException
-
execute
protected void execute(org.springframework.batch.core.job.Job job, org.springframework.batch.core.job.parameters.JobParameters jobParameters) throws org.springframework.batch.core.launch.JobExecutionAlreadyRunningException, org.springframework.batch.core.launch.JobRestartException, org.springframework.batch.core.launch.JobInstanceAlreadyCompleteException, org.springframework.batch.core.job.parameters.InvalidJobParametersException - Throws:
org.springframework.batch.core.launch.JobExecutionAlreadyRunningExceptionorg.springframework.batch.core.launch.JobRestartExceptionorg.springframework.batch.core.launch.JobInstanceAlreadyCompleteExceptionorg.springframework.batch.core.job.parameters.InvalidJobParametersException
-