Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command line properties not taking precedence over other property sources #167

Closed
mvaal opened this issue Jun 4, 2015 · 6 comments
Closed
Labels

Comments

@mvaal
Copy link

mvaal commented Jun 4, 2015

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.

@spencergibb
Copy link
Member

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

@mvaal
Copy link
Author

mvaal commented Jun 4, 2015

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.

@spencergibb
Copy link
Member

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

@mvaal
Copy link
Author

mvaal commented Jun 5, 2015

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.

@satar
Copy link

satar commented Jun 6, 2015

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...

@mvaal
Copy link
Author

mvaal commented Jun 6, 2015

Excellent suggestion, I will try this. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants