Setting the default active profile in Spring-boot

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

What you are doing here is setting the default default profile (the profile that is used on any bean if you don't specify the @Profile annotation) to be production.

What you actually need to do is set the default active profile, which is done like this:

spring.profiles.active=production

add --spring.profiles.active=production

Example:

java -jar file.jar --spring.profiles.active=production