Spring Boot Multiple Configuration File

Spring Boot Multiple Configuration File

There are many ways you could set up multiple configuration file in Spring Boot application. In last tutorial you saw how to create application with default configuration file.

  • If you need to use common properties file just put application.properties in \src\main\resources\ folder and Spring Boot load this file as default. If you want use multiple configuration where some of them is load based on the environment then you will have define properties file accordingly. Let’s see from sample project below:


Spring Boot Multiple Configuration File

  • As you see above properties file created accordingly based on environment. Default properties will be read from application.properties file and to load other properties file you will have to pass spring.config.location using below VM argument separated by comma:

-Dspring.config.location=file:.\src\main\resources\db\db-UAT.properties,file:.\src\main\resources\DEV.properties

  • Eclipse:

Spring Boot Multiple Configuration File

  • For more information please visit Spring official documentation here

Download complete project: SpringBootTomcat

One thought on “Spring Boot Multiple Configuration File”

Leave a Reply

Your email address will not be published. Required fields are marked *