Pass system property to spring boot
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/
you can also do it like this:
public static void main(String[] args) {
System.setProperty("key", "value");
SpringApplication.run(MyApplication.class);
}
You can pass it on the command line:
java -Dlibrary.system.property=value -jar myapp.jar
If you are using spring-boot maven plugin to execute the application, try (no line breaks)
mvn spring-boot:run -Drun.jvmArguments="-Xms2048m -Xmx4000m -XX:MaxPermSize=2048m
-Dlibrary.system.property=value"
Refer maven plugin for additional details