Home > Software design >  Run -jar with args and use args in Spring
Run -jar with args and use args in Spring

Time:02-24

I need to run jar with static parameter, for example, java -jar myapp-1.0.0.jar /path/static/myfolder, and use this path "/path/static/myfolder" in my code. So, I know how to get this parameters in PSVM (String..args), but how to get it in Spring? Is there annotation for this or may be in properties file>

CodePudding user response:

for example: java -jar -Dtest=abcd myapp-1.0.0.jar.

you can use System.getProperty("test") to get value.

-D{parameter} needs to be before that jar

CodePudding user response:

sorry, my english is not good. I will learn more infomation on how to write good answers. enter image description here

  • Related