Run the job through CommandLineJobRunner: java -jar
batchprimer-1.0.jar META-INF/spring/module-context.xml job1
even with a complete target folder you have to provide the classpath information for the java command, to ease the configuration you can try it with an all-in-one executable jar e.g. with maven-shade-plugin or an executable shell script (.bat/.sh) with all needed libraries, e.g. with appassembler-maven-plugin
maven-shade-plugin example configuration (creates additional jar):
<plugin>
<!-- create an all-in-one executable jar with maven-shade-plugin
bound to phase:package
special handling for spring.handlers/spring.schemas files
to prevent overwriting (maven-shade-plugin joins them to
one file)
usage:
cd to <project>/target
java -jar hello-world-java-1.0-SNAPSHOT-executable.jar spring/batch/job/hello-world-job.xml helloWorldJob
-->
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.springframework.batch.core.launch.support.CommandLineJobRunner</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
<shadedArtifactAttached>true</shadedArtifactAttached>
<!-- configures the suffix name for the executable jar
here it will be '<project.artifact>-<project.version>-executable.jar'-->
<shadedClassifierName>executable</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
example appassembler configuration (creates subfolder structure and .bat/.sh):
<plugin>
<artifactId>appassembler-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>1.1.1</version>
<configuration>
<repositoryLayout>flat</repositoryLayout>
<installArtifacts>false</installArtifacts>
<target>${project.build.directory}/appassembler</target>
<defaultJvmSettings>
<initialMemorySize>512M</initialMemorySize>
<maxMemorySize>1024M</maxMemorySize>
<extraArguments>
<extraArgument>-Dlog4j.configuration=../etc/log4j/log4j.properties</extraArgument>
</extraArguments>
</defaultJvmSettings>
<configurationDirectory>etc</configurationDirectory>
<daemons>
<daemon>
<id>applicationName</id>
<mainClass>org.springframework.batch.core.launch.support.CommandLineJobRunner</mainClass>
<commandLineArguments>
<commandLineArgument>spring/job-runner.xml</commandLineArgument>
<commandLineArgument>helloWorldJob</commandLineArgument>
<commandLineArgument>input.file.pattern=file:.../**/*.txt</commandLineArgument>
</commandLineArguments>
<platforms>
<platform>booter-unix</platform>
<platform>booter-windows</platform>
</platforms>
</daemon>
</daemons>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>generate-daemons</goal>
<goal>create-repository</goal>
</goals>
</execution>
</executions>
</plugin>