简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM