Read from multiple .properties files in Spring Boot

This post demonstrates how to read properties from multiple .properties files in Spring Boot.


  1. Java 8
  2. Spring Boot 1.5.8.RELEASE
  3. Spring Initialzr
  4. IntelliJ IDEA or Eclipse

Use Case

We have the following .properties files to read from and into an object’s properties.


This file has this content:


While this one has:


This file has:

All these files are located under the resources directory in the Maven project.

A Singleton bean

We use a singleton bean whose properties are mapped to entries in 3 separate .properties files.

We use @PropertySource and an array of locations of the files in the classpath. Notice application.properties is not specified as it is implicitly included in the @PropertySource by Spring Boot.

Alternatively, we could use @PropertySources.

Demo and Test

We have a main class that simply displays the values from the bean.

This outputs:

Download the codes


Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert