I don't know how to call a Job defined in Spring Batch using CommandLineJobRunner
, documentation details are not enough for me.
I've followed the Spring Batch official guide to write Jobs in Spring Batch using Java annotations e.g. @EnableBatchProcessing
because I wanted to avoid XML configuration files for the description of the job, the steps, etc.
So far I have:
- a configuration class (
com.package.bla.bla.ClassContainingTheBatchConfiguration
see below) where I've put all the stuff definingItemReader
,ItemProcessor
,ItemWriter
,Job
, andStep
(withreturn jobs.get("nameOfTheJob")
see below) using a@Bean
annotaion. - a class with a
main
method withSpringApplication.run(...)
and and annotation with@ImportResource("classpath:META-INF/spring/applicationContext.xml")
to import some beans I need when processing the data in the Job.
On the Maven side I am currently using some plugins:
maven-jar-plugin
specifying<addClasspath>true</addClasspath>
and the class containing the main method in the tag<mainClass>
maven-assembly-plugin
because I would like a unique executablejar
containing all the stuff in the dependencies, I am using<phase>package</package>
to be able to build the jar in thepackage
phase, I am also using<goal>single</goal>
to be able to properly build the jar using theassembly
maven-compiler-plugin
specifying I am using Java 1.7
I think I've configured all the things I need to configure, however after having a Maven BUILD SUCCESS
I am not able to run the job from the command line:
java -cp ./target/JAR_FILE_NAME.jar org.springframework.batch.core.launch.support.CommandLineJobRunner com.package.bla.bla.ClassContainingTheBatchConfiguration nameOfTheJob
Is throwing IOException
due to the java.io.FileNotFoundException
regarding com.package.bla.bla.ClassContainingTheBatchConfiguration
. How should I specify the parameters in the command line in order to get the Job executed?