Running a specific spring batch job amongst several jobs contained withing a spring boot fat jar

7.1k Views Asked by At

I am trying to run a spring batch job from a spring boot fat jar and I am having issues referencing the nested jars.

Here is the command I use:

java -cp bignibou-batch-core/build/libs/bignibou-batch-core.jar:lib/spring-batch-core-3.0.3.RELEASE.jar org.springframework.batch.core.launch.support.CommandLineJobRunner com.bignibou.batch.configuration.BatchConfiguration mailingJob

Notice how I reference the nested spring batch jar using the colon. Why is this not working?

It says it cannot find the main class:

Erreur : impossible de trouver ou charger la classe principale org.springframework.batch.core.launch.support.CommandLineJobRunner
1

There are 1 best solutions below

1
On BEST ANSWER

I turns out that there is a nice option to choose one job (out of multiple jobs) from within a fat jar:

--spring.batch.job.names=jobOne,jobThree

Only jobOne & jobThree will run even if jobTwo also exists.

See http://docs.spring.io/spring-boot/docs/current/reference/html/howto-batch-applications.html for documentation.

So as far as I am concerned, this sorted my problem:

java -jar bignibou-batch-core/build/libs/bignibou-batch-core.jar --spring.batch.job.names=mailingJob