'Spring active profiles setting override [duplicate]
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
Solution 1:[1]
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"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
