-2

I want to execute environment specific application-{PROFILE}.properties file (which I have set in my environment variable) in my application. So let us say I have environment defined as "prod", so the application should use application-prod.properties file. Kindly suggest me how to achieve this. Thank you in advance.

Edit 1: I am using java -jar MyApp.jar to run. And suppose I have 4 application.properties files in my app, and I want my app to use the application-dev.properties file ( here dev is defined in my environment variable)

Edit 2: I can't use spring.profiles.active in application.properties file, because in that case I will have to change every time I will run my jar in different env, let us say dev,uat and prod.

Ashish Burnwal
  • 626
  • 8
  • 13
  • 1
    https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html – Aritz Dec 14 '17 at 10:23

1 Answers1

0

Run with following maven command.

mvn clean install -P<PROFILE_NAME>

It will use properties file based on the profile.

vikas
  • 270
  • 2
  • 11
  • I have application-prod.properties file, tried running mvn clean install -P "application-prod.properties" but it is saying The requested profile "application-prod.properties" could not be activated because it does not exist. – Ashish Burnwal Dec 14 '17 at 11:40