Question
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
In my Spring Boot application, i want to create environment specific properties file. The packaging type of my application in war and i am executing it in embedded tomcat. I use sts and execute the main from sts itself.
- Can i have environment specific properties file like application-${env-value}.properties?
In above case, env-value will have values as local/devl/test/prod
-
Where to set the env-value file? For local, i can set it as the jvm argument through sts
-
Who reads the application.properties in Spring Boot application.
-
How to load the environment specific properties file? For ex - if i set the database uid,pwd, schema etc in environment specific property file, in that case will the datasource be able to understand the properties in it?
-
Can i use application.properties and application-local.properties file at same time?
Answer
Spring Boot already [has support](http://docs.spring.io/spring- boot/docs/current/reference/html/boot-features-external-config.html) for [profile](http://docs.spring.io/spring/docs/current/spring-framework- reference/html/beans.html#beans-definition-profiles) based properties.
Simply add an application-[profile].properties
file and specify the profiles
to use using the spring.profiles.active
property.
-Dspring.profiles.active=local
This will load the application.properties
and the application- local.properties
with the latter overriding properties from the first.