Properties file
- Default properties file is
application.properties
- Default profiles file is
application-default.properties
If application have the following properties file
// application.properties
app.msg=Hello World
app.version=1.0.0
// application-default.properties
app.msg=Default
// application-prod.properties
app.msg=Prod
java -jar app.jar
should get
app.msg=Default
app.version=1.0.0
java -jar -Dspring.profiles.active=prod app.jar
should get
app.msg=Prod
app.version=1.0.0
Start Spring Boot with profile
// Java
java -jar -Dspring.profiles.active=prod app.jar
// Maven
mvn spring-boot:run -Dspring-boot.run.profiles=prod
Windows PowerShell required double quote around parameter
java -jar "-Dspring.profiles.active=prod app.jar"
mvn spring-boot:run "-Dspring-boot.run.profiles=prod"
Top comments (0)