First of all, with the solution below, is necessary to understand that always the spring boot will read the application.properties
file. So the other's profile files only will complement and replace the properties defined before.
Considering the follow files:
application.properties
application-qa.properties
application-prod.properties
1) Very important. The application.properties
, and just this file, must have the follow line:
[email protected]@
2) Change what you want in the QA and PROD configuration files to see the difference between the environments.
3) By command line, start the spring boot app with any of this options:
It will start the app with the default application.properties
file:
mvn spring-boot:run
It will load the default application.properties
file and after the application-qa.properties
file, replacing and/or complementing the default configuration:
mvn spring-boot:run -Dspring.profiles.active=qa
The same here but with the production environment instead of QA:
mvn spring-boot:run -Dspring.profiles.active=prod