'Run -jar with args and use args in Spring

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>



Solution 1:[1]

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

Solution 2:[2]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peter Csala
Solution 2 JeffreyXue