I am using Spring Boot for creating microservices. By default it uses application.properties
for configurations. But I have a requirement to use another property file which is outside of jar file. I tried following options in eclipse JVM arguments while running bootRun
from Gradle but still it didn't work.
-Dspring.config.location=c:/another.properties
-Dspring.config.additional-location=c:/another.properties
-Dspring.config.import=c:/another.properties
I also tried adding the above properties inside application.properties but still @Value
annotation added in controller class which refers a property from c:/another.properties
is not getting injected.
The spring.config.additional-location
should be a folder and the value should end with /
From the documentation:
You can provide default values for your application in application.properties (or whatever other basename you choose with spring.config.name) in one of the default locations. These default values can then be overridden at runtime with a different file located in one of the custom locations.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.