How to make Spring Boot command line parameters work with JCommander ?

291 views
Skip to first unread message

Sabir Khan

unread,
Jul 13, 2017, 11:57:38 PM7/13/17
to jcommander
Hi, 


I am using [JCommander API](http://jcommander.org/) for a Spring Boot - Spring Batch project. 

Project has multiple jobs and I need to pass job name as parameter so I can launch specific jobs . 

    java -jar myJar.jar -jobName job1

Now, if my `job1` is running and I wish to launch `job2` at that time, I couldn't do that since **port is already is in use**. So I would be able to launch `job2` only when `job1` is finished. 

If I try to launch `job2` at different port , 

`java -jar myJar.jar -jobName job2 --server.port=8090` 

then jCommander is not letting it through since I have not defined `server.port` in JCommander configuration and even if I do that , Spring Boot picks property from property file only and tries to run at same port - `8080`. 

How to handle this scenario? 


Reply all
Reply to author
Forward
0 new messages