Spring-cloud-config: Command line properties not taking precedence over other property sources

Created on 4 Jun 2015  路  6Comments  路  Source: spring-cloud/spring-cloud-config

I am using spring-cloud-config-client 1.0.1.RELEASE and it is not taking command line properties over the property file in the cloud config server.
From the spring-boot docs on external configuration, it seems like this should always be the case:
http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-command-line-args
My current work around is to completely remove the property from my default and profile config files in the config repo, but it would be nice to have this option.
Is there a way to change the property source order? Or is this the intended functionality?
Thanks.

question

Most helpful comment

I had a similar issue. How I got around it was to provide an override in
the property located in the application's config located in the repo,
something like this:

dialer.connection.port=${port:9125}

Then I could actually override it by passing an argument: --port=9999

Sorry, cleaned up the copied reply as I had replied through email client instead of directly...

All 6 comments

If I'm not mistaken, this is the intended functionality.

So given a spring-boot application running with cloud-config, the only option to overwrite a property in the default config file is to check in a profile to the config repo with the changed property in it and run with the profile? I can work with this, but seems like you should have the ability to change it from command line if needed (e.g., to quickly test a different server, but only for a short period of time). It would be great to understand why this is intended functionality. Thanks for your feedback and quick response.

You can turn off the config server for a given instance, if you want, spring.cloud.config.enabled=false.

Not quite what I am looking for since I think this would require me to pass all properties in through command line then, I would like to just override one property but still use all other properties from config server (just like it would work with a properties file on the classpath).
After looking through the code, I think I understand what is going on. In BootstrapApplicationListener (which is in spring-cloud-context), the property order is bootstrap, commandLineArgs, etc... Since cloud-config URI resides in bootstrap property source, all properties in cloud-config will take priority over all other properties.
What I am looking for is for cloud-config to act the same as if properties were retrieved from a file in the classpath.
In other words, I need cloud-config to not be part of bootstrap property source, but instead have its own property source that resides between 5 and 6 in the Externalized Configuration order. Right now it is at 0 which makes it impossible for applications to override values.
This doesn't seem to have a work around currently, so I will try to manage it through multiple profiles in the config repo.

I had a similar issue. How I got around it was to provide an override in
the property located in the application's config located in the repo,
something like this:

dialer.connection.port=${port:9125}

Then I could actually override it by passing an argument: --port=9999

Sorry, cleaned up the copied reply as I had replied through email client instead of directly...

Excellent suggestion, I will try this. Thanks!

Was this page helpful?
0 / 5 - 0 ratings