Spring Boot profiles
In this article, we will see profiles for spring boot project -
Github Link -
Download
Every enterprise application has many environments, like:
Dev | Test | Stage | Prod | UAT / Pre-Prod
Each environment requires a setting that is specific to them. For example, in DEV, we do not need to constantly check database consistency. Whereas in TEST and STAGE, we need to. These environments host specific configurations called Profiles.
How do we Maintain Profiles?
In spring boot application, we need different configurations for different environments. We have application.properties file to maintain application specific properties. In order to create profiles for different environments , we need to create various properties files as below -
DEV — application-dev.properties
TEST- application-test.properties
PROD — application-prod.properties
Step 1: Create below project structure in IntelliJ
Step 2: We are creating 3 different property files for below mentioned environments -
DEV — application-dev.properties
TEST- application-test.properties
PROD — application-prod.properties
Of course, the application.properties will remain as a master properties file, but if we override any key in the profile-specific file, the latter will gain precedence.
Step 3: Specify in application.properties file which environment property needs to be loaded
spring.profiles.active=prod
spring.application.name=springbootprofiles
app.message






