Java Reference
In-Depth Information
When you call CommandLineJobRunner from a command line or script, there are three required
parameters and four optional ones, as detailed in Table 6-1.
Table 6-1. CommandLineJobRunner Parameters
Parameter
Use
jobPath
Provides the path to the ApplicationContext configuration
containing a job configuration.
-restart
Tells Spring Batch to execute the last failed execution for the job
identified
-stop
Stops an already running JobExecution
-abandon
Tells Spring Batch to abandon a previously stopped execution
-next
Increments the required parameter in the sequence configured
by the JobParametersIncrementer of the job specified
jobIdentifier
Gives the name or id of the job as it's specified in the
ApplicationContext . (used in conjunction with the -stop , -
abandon , and -restart parameters)
jobParameters
Specifies a list of key=value pairs to be passed into the job as
JobParameters
Although you've used CommandLineJobRunner almost exclusively to execute jobs up to now, as you
can see, there is more that this small tool can do for you. The path to your job's XML file, and the -next
and job parameter options, should all be familiar because they have been covered previously.
The build process you've been using with the Project Object Model (POM) included in simple-cli
builds a jar file with CommandLineJobRunner configured as the main class. To use it, you need the jar file in
a directory with a lib folder containing all dependencies. If you look at the <project_home>/target/
directory, you see the jar file that has been built along with the lib directory with the required
dependencies; however, the name may not be the most intuitive (for example, spring-batch-simple-
cli-2.1.3.RELEASE.jar ). To update the build process to build a more appropriate jar name, you can
change the POM file to generate your artifact with the appropriate name. Listing 6-2 shows the POM
update that changes the name of the jar to helloWorld.jar .
Listing 6-2. Renaming the Maven Artifact to helloWorld.jar
...
<build>
<finalName>helloWorld</finalName>
...
</build>
...
 
 
Search WWH ::




Custom Search