Tom Donohue Tom Donohue

Spring Boot command line arguments example

When you run a Spring Boot application from the command line, and you want to do any of the following:

Then start your application like this:

java [java options...] \
    -jar path/to/spring-boot-application.jar \
    --spring.property.name=value, ... \
    --application.property.name=value, ... \

Example

This example first compiles a Spring Boot application with Maven.

Then, it starts the application. It sets HTTPS proxy configuration, unlocks features for Mission Control, makes Spring use a local Profile, and sets some custom application properties:

$ mvn clean package
$ java -XX:+UnlockCommercialFeatures -XX:+FlightRecorder \
    -Dhttps.proxyHost=yourproxy.yourcompany.com \
    -Dhttps.proxyPort=8080 \
    -Dhttps.proxyUser=$PROXY_USER \
    -Dhttps.proxyPassword=$PROXY_PASS \
    -jar target/application-1.0.0-SNAPSHOT.jar \
    --spring.profiles.active=local \
    --breakfast.eggs=poached \
    --dinner.eggs=boiled

Comments

What do you think? You can use Markdown in your comment.

To write code, indent each line with 4 spaces. Or, to paste a lot of code, you can put it in pastebin.com and share the link in your comment.