Override remote resources with local resources
ismagc7 opened this issue · 2 comments
I'm using :
- SpringBoot 3.2.0
- Java 17
- Spring Cloud Config Server 3.1.4
- Spring cloud Config Client 4.0.3.
I tried to override the remote resources with the local resources to develop. It has been impossible.
This feature improves the development experience, to test properties and change it quickly.
Example Git Repository with properties:
ServiceA
|_ServiceA-profileX.properties
|_ServiceA-profileY.proeprties
|_ServiceA-profileZ.properties
application-profileX.properties
application-profileY.properties
application-profileZ.properties
Into application.profileZ.properties we have a common properties in all microservices for profile Z.
Into ServiceA-profileZ.properties we have the specific properties to microservice A with profile Z.
In my microservice we have a bootstrap.properties with this properties:
spring.application.name=serviceA (in this example)
spring.profiles.active=Z (in this example)
spring.config.import=configserver:<url_to_config_server>
management.endpoints.web.exposure.include=health,info,refresh
spring.cloud.config.username=
spring.cloud.config.password=
When i launch mi service the remote configuration loads perfectly. However, i would like to override the remote configuration with a local file application.properties, if a local property matches withe remote property, I prefer the preference to be the local file rather than the remote one.
You could take this approach
https://docs.spring.io/spring-cloud-config/reference/server/environment-repository/using-bootstrap-to-override-properties.html
Or if you are using spring.config.import
you could try specifying your local configuration file(s) AFTER the config server in the list.
Perfect! i tried the first approach and it has worked.
[SOLUTION]
Into config cloud client bootstrap.properties:
spring.cloud.config.uri=<config_cloud_server_url>
And into service remote properties (serviceA-profileZ.properties):
spring.cloud.config.allowOverride=true
spring.cloud.config.overrideNone=true
Important
The properties allowOverride and overrideNone should be into REMOTE properties
Thanks @ryanjbaxter