Reputation: 7330
I have a spring-boot 2.1.3.RELEASE application with multiple properties
files.
In my /src/main/resources
I have my-app.properties
and profiled my-app-local.properties
.
Also, outside the project I have another profiled properties file /config/my-app-local.properties
.
The point of this configuration is to have the following properties hierarchy:
/resources/my-app.properties
/resources/my-app-local.properties
/config/my-app-local.properties
So when I try to run the application with the following parameters:
--spring.profiles.active=local --spring.config.name=my-app --spring.config.location=config/my-app.properties
the application fails to start because it can't find any properties
files.
However, this configuration and parameters worked perfectly on spring-boot 1.5.19.RELEASE. How can the same be achieved in spring-boot 2?
Upvotes: 0
Views: 446
Reputation: 39978
use spring.config.additional-location
doc
When custom config locations are configured by using
spring.config.location
, they replace the default locations. For example, ifspring.config.location
is configured with the valueclasspath:/custom-config/,file:./custom-config/,
the search order becomes the following:
file:./custom-config/
classpath:custom-config/
Alternatively, when custom config locations are configured by using
spring.config.additional-location,
they are used in addition to the default locations. Additional locations are searched before the default locations. For example, if additional locations ofclasspath:/custom-config/,file:./custom-config/
are configured, the search order becomes the following:
file:./custom-config/
classpath:custom-config/
file:./config/
file:./
classpath:/config/
classpath:/
Upvotes: 1