In my Spring Cloud application I would like to let user to change some default settings. I keep the default properties in application.yml inside the jar and start my application with
-Dspring.config.additional-location=/some_location/properties_override.yml
When the user changes properties_override.yml I wanted to reload configuration without restarting the application. Spring config server seems to be an ideal mechanism for it, but I cannot figure out if it can work with the properties located locally on the file system. When I am looking at spring.cloud.config it seems to only only support git, jdbc and svn servers. None of these mechanisms is an option for me I am wondering if thee is a way to use Spring Cloud Config to reload configuration from a local file on the file system?
Using "native" profile seems to be a right way to go, but it created another problem: I need two entries in cloud.config.server.native.searchLocations: one for application.yml on the classpath (in module's src\main\resources\config folder) and the second one on the file path. Setting searchLocations to:
searchLocations: classpath:/config,file:/some_location/properties_override.yml
The properties in application.yml are not picked up.
If my application.yml I have entry
custom:
property: foo
There is a Spring bean which has property tagged with
@Value("${custom.property"})
Without searchLocations in application.yml the property is being resolved. With searchLocations I am getting an exception:
java.lang.IllegalArgumentException: Could not resolve placeholder 'custom.property' in value "${custom.property}"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:172) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:237) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:211) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]