Skip to content

Instantly share code, notes, and snippets.

@lynas
Created May 14, 2019 04:19
Show Gist options
  • Save lynas/1a0e213daf3cc584bdd24371668f71f7 to your computer and use it in GitHub Desktop.
Save lynas/1a0e213daf3cc584bdd24371668f71f7 to your computer and use it in GitHub Desktop.
Spring boot run command with profile and its specific location

Prerequisite

Install jdk-8 to the system and add it to system path. Run following command to verify jdk installation

java -version

Running test

./gradlew clean test

Run project [dev profile]

./gradlew bootRun --args ' --spring.profiles.active=dev'

Change dev profile config at following location

src/main/resources/application-dev.properties

Run project using config from external location

./gradlew bootRun --args ' --spring.profiles.active=prod --spring.config.location=/home/config/application-prod.properties'

API doc

After running the app go to the following URL in the browser

http://localhost:8080

Create executable jar

./gradlew bootJar

Run jar with default profile

java -jar jarName

Run jar with specific profile

java -jar jarName --spring.profiles.active=dev

Run jar with specific profile and specific profile location

java -jar jarName --spring.profiles.active=prod --spring.config.location=/home/config/application-prod.properties

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment