SpringBoot : How to set active profile in spring boot application

Points To Remember

There are two ways to set the spring profiles

  • Using OS environment variables
  • Using -D arguments

How to set active profile in spring boot application

If you want to set Operating System Environment variables for your application the you can do as follows

export SPRING_PROFILES_ACTIVE=development
export SERVER_PORT=8090
gradle bootRun
java -jar build/libs/demo-1.0.0.jar

If you want to specify it each time while running jar then you can do as follows

java -jar -Dspring.profiles.active=development build/libs/dem-1.0.0.jar
java -jar -Dserver.port=8090 build/libs/demo-1.0.0.jar

No comments :

Post a Comment