Spring / Spring batch Interview questions
What is CommandLineJobRunner in Spring Batch?
CommandLineJobRunner is one of the ways to bootstrap your Spring batch Job. The xml script launching the job needs a Java class main method as as entry point and CommandLineJobRunner helps you to start your job directly using the XML script.
The CommandLineJobRunner performs 4 tasks.
- Load the appropriate ApplicationContext.
- Parse command line arguments into JobParameters.
- Locate the appropriate job based on arguments.
- Use the JobLauncher provided in the application context to launch the job..
The CommandLineJobRunner arguments are jobPath, the location of the XML file that will be used to create an ApplicationContext and the jobName, the name of the job to be run.
These arguments must be passed in with the path first and the name second. All arguments after these are considered to be JobParameters and must be in the format of 'name=value'.
More Related questions...