SpringBoot Arguments

I recently ran into an issue with our deployment of a SpringBoot application because of some confusion around how to pass arguments when launching it.

The command to run an app looks like this java -jar ${APP_NAME}.jar

You can pass arguments to Spring boot either

  • Using the -D Java property notation by adding it as a VM argument between java and -jar

  • Using -- style notation after the jar name

For example, java -DenvTarget=dev test-api.jar --server.port=8008 would set the envTarget property to dev and the server.port to 8008