Luke
Luke

Reputation: 67

Spring Boot: How to create 3 profiles and implement in spring boot

I want to create 3 profiles to access the database based on the enviroment

Instead of writing all the properties in a single file. I want the properties has to be split into 3 based on enviroment (Qlty,Prod,Dev). That is

1.application_prod.properties --should contain all production related details
2.application_qlty.properties --should contain all qlty related details
3.application_dev.properties  --should contain all dev related details

How to implment the above 3 profiles in spring boot and how to select the profile based on the type of enviroment. what is the best practice to implement the above in an easy manner

Upvotes: 0

Views: 316

Answers (1)

Shakirov Ramil
Shakirov Ramil

Reputation: 1553

you just add profile on run options

java -jar app.jar --spring.profiles.active=dev

or with maven

mvn spring-boot:run -Dspring-boot.run.arguments="--spring.profiles.active=dev"

One remark. profile on property file writes with "-"

application-dev.properties

Upvotes: 1

Related Questions