Share the joy
There are two ways to run your batch job.
First is to use console command. In order to do this, we need to compile the batch job, and saves all dependency jar in a lib file. We just write the following in the maven pom.xml(I refered this good example from mkyong.)
<plugin> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/lib/</outputDirectory> </configuration> </execution> </executions> </plugin>
After that, we go to the target folder, and run following command:
java -cp “dependency-jars/*;SpringBatchExample.jar” org.springframework.batch.core.launch.support.CommandLineJobRunner spring\batch\jobs\job-hello-world.xml pliJob
Another way to run batch job is like we run normal main() in App.java. We compile it. And we use java -cp to call the App.class in the jar file:
java -cp SpringBatchExample.jar com.pli.project.sba.App