is there any other way to activate the profile and use the corrosponding application-{phase}.yml?

29 Views Asked by At

I have a spring application which has an application.yml and multiple application-{PHASE}.yml files. By default the application uses application.yml file. Now i require that it uses the application-PRD.yml. When i try to use spring.profiles.active=PRD it doesnot use application-PRD.yml. So is there any other way to activate the particular yml file?

I tried activating the spring profile using spring.profiles.active=PRD But still the application uses application.yml by default.

1

There are 1 best solutions below

0
J Asgarov On

It must work so you are probably setting it somehow wrong. Use either of these two commands (note that the way you have to specify the active spring profile is different for mvn spring-boot:run)

  • mvn clean package && java -jar -Dspring.profiles.active=PRD ./target/NAME_OF_YOUR_JAR.jar
  • mvn clean package && mvn spring-boot:run -Dspring-boot.run.profiles=PRD