0

Suppose the spring active profiles are set in the command line, is it possible to override the command line setting via some setting in the application ? I have tried to set it in the application yaml file but it doesn't override and the system is still using the command line setting.

//command line
java -Dspring.profiles.active=testing


//application yaml
spring:
 profiles:
  active: dev
once
  • 536
  • 7
  • 21

1 Answers1

2

Spring Boot allows you to externalize your configuration and you can pass in individual properties as command-line arguments with highest priority .

java -jar your-app.jar --spring.profiles.active=testing

If you're using maven

mvn spring-boot:run -Dspring-boot.run.arguments="--spring.profiles.active=testing"

In case of spring boot

mvn spring-boot:run -Drun.arguments="--spring.profiles.active=testing"
Lunatic
  • 1,519
  • 8
  • 24