Executing a job from the command line
A simple and robust way to execute a job is to use the command-line interface. This allows you to use a standard cron
job (use the AT
command on Windows) to schedule it, so that the job will be executed even if the web application is down. It's also convenient for testing and debugging a job.
Getting Ready
We'll use the job defined in the Creating a job recipe.
How to do it…
Follow these steps to execute the job from the command line:
Declare the
maven-assembly-plugin
inpom.xml
(underbuild
/plugins
):<plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass> org.springframework.batch.core.launch.support. CommandLineJobRunner </mainClass> </manifest> </archive> <descriptorRefs> <...