Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass system property to spring boot

A library I need to use reads system property in the following way:

System.getProperty("library.system.property")

Is there any way to pass such a property to spring boot while starting the app or do I need to set it in the system?

like image 362
zibi Avatar asked Dec 15 '15 19:12

zibi


1 Answers

Update 2020-01-08

For spring-boot 2.2.2.RELEASE while develop

mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dmy_-Dmy_system_properties=test1"

For spring-boot 1.5.x.RELEASE or below while develop

mvn spring-boot:run -Drun.jvmArguments="-Dmy_system_properties=test1"

For run as jar

java -Dmy_system_properties=test1 -jar service.jar 

You can try with a runnable example, here https://www.surasint.com/spring-boot-pass-system-properties-in-command-line/

like image 116
Surasin Tancharoen Avatar answered Sep 21 '22 15:09

Surasin Tancharoen