|
31 | 31 | import org.springframework.batch.core.job.Job; |
32 | 32 | import org.springframework.batch.core.job.JobExecution; |
33 | 33 | import org.springframework.batch.core.job.JobExecutionException; |
| 34 | +import org.springframework.batch.core.job.parameters.InvalidJobParametersException; |
34 | 35 | import org.springframework.batch.core.job.parameters.JobParameters; |
35 | | -import org.springframework.batch.core.job.parameters.JobParametersInvalidException; |
| 36 | +import org.springframework.batch.core.launch.JobExecutionAlreadyRunningException; |
| 37 | +import org.springframework.batch.core.launch.JobInstanceAlreadyCompleteException; |
36 | 38 | import org.springframework.batch.core.launch.JobOperator; |
37 | | -import org.springframework.batch.core.launch.NoSuchJobException; |
38 | | -import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; |
39 | | -import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; |
40 | | -import org.springframework.batch.core.repository.JobRestartException; |
| 39 | +import org.springframework.batch.core.launch.JobRestartException; |
41 | 40 | import org.springframework.beans.factory.InitializingBean; |
42 | 41 | import org.springframework.beans.factory.annotation.Autowired; |
43 | 42 | import org.springframework.boot.ApplicationArguments; |
@@ -146,10 +145,11 @@ public void run(ApplicationArguments args) throws Exception { |
146 | 145 |
|
147 | 146 | public void run(String... args) throws JobExecutionException { |
148 | 147 | logger.info("Running default command line with: " + Arrays.asList(args)); |
149 | | - launchJobFromProperties(StringUtils.splitArrayElementsIntoProperties(args, "=")); |
| 148 | + Properties properties = StringUtils.splitArrayElementsIntoProperties(args, "="); |
| 149 | + launchJobFromProperties((properties != null) ? properties : new Properties()); |
150 | 150 | } |
151 | 151 |
|
152 | | - protected void launchJobFromProperties(@Nullable Properties properties) throws JobExecutionException { |
| 152 | + protected void launchJobFromProperties(Properties properties) throws JobExecutionException { |
153 | 153 | JobParameters jobParameters = this.converter.getJobParameters(properties); |
154 | 154 | executeLocalJobs(jobParameters); |
155 | 155 | executeRegisteredJobs(jobParameters); |
@@ -179,14 +179,14 @@ private void executeRegisteredJobs(JobParameters jobParameters) throws JobExecut |
179 | 179 | if (this.jobRegistry != null && StringUtils.hasText(this.jobName)) { |
180 | 180 | if (!isLocalJob(this.jobName)) { |
181 | 181 | Job job = this.jobRegistry.getJob(this.jobName); |
| 182 | + Assert.notNull(job, () -> "No job found with name '" + this.jobName + "'"); |
182 | 183 | execute(job, jobParameters); |
183 | 184 | } |
184 | 185 | } |
185 | 186 | } |
186 | 187 |
|
187 | | - protected void execute(Job job, JobParameters jobParameters) |
188 | | - throws JobExecutionAlreadyRunningException, NoSuchJobException, JobRestartException, |
189 | | - JobInstanceAlreadyCompleteException, JobParametersInvalidException { |
| 188 | + protected void execute(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, |
| 189 | + JobRestartException, JobInstanceAlreadyCompleteException, InvalidJobParametersException { |
190 | 190 | JobExecution execution = this.jobOperator.start(job, jobParameters); |
191 | 191 | if (this.publisher != null) { |
192 | 192 | this.publisher.publishEvent(new JobExecutionEvent(execution)); |
|
0 commit comments