I have a Spring boot application that is divided in several modules.
The main module runs the application and has an application.properties file in the resource
Spring Boot reads the property files in the following order. (From Spring Boot in Action)
- Externally, in a /config subdirectory of the directory from which the application is run
- Externally, in the directory from which the application is run
- Internally, in a package named “config”
- Internally, at the root of the classpath
The list is ordered by precedence (properties defined in locations higher in the list override those defined in lower locations).
So placing application.properties in a config sub-directory will give it a higher priority. In the following configuration, the application.properties from module_a will take precedence. You can add common defaults in application.properties and override them in individual modules by placing the configuration file in config/application.properties.
+common_module
+src
+main
+java
+resources/application.properties
+module_a
+src
+main
+java
+my/package/Application.java
+resources/config/application.properties