-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Document precedence of property source with @ConfigurationProperties#locations #5111
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
Comments
It sounds like we need to clarify the documentation as this is working as designed. When you specify one of more explicit locations for |
Perhaps it would be nice to introduce an attribute on configurationproperties to allow this behaviour to be overriden. At least in my case I just want to include this file as a configuration source and allow the default behaviour of the spring boot configuration to take over with overrides from the command line |
@vcetinick that's not how you should do it then. That |
Just a note on how I went down this path. I have a multi module project and to keep my configuration dry, I want to keep each modules configuration isolated (by classpath) by uniquely naming each modules configuration i.e. database.yml inside a database.jar. This meant that the parent jar (the main application) would have its configuration defined the normal spring way in application.yml and would not compete with the child modules. |
@snicoll we share very same goals and problems with @vcetinick and I don't see the way out.
Note, that we have to use ConfigurationProperties since we rely on spring cloud config server in cloud environment, so we need to be able to change properties in real-time. Can you suggest the optimal way to solve this problem? |
I would use |
Not sure I understand.
|
As the documentation states, you can configure them using System properties or environment variables. You can also pass them into your application as command line arguments or configure them as default properties on your
By configuring
|
Thanks, clearly I can launch the apps with -Dspring.config.name=projectA,projectB. |
The only requirement is to get the configuration of This issue isn't really the right place to continue this discussion as we've gone way beyond the behaviour of |
I am experiencing some strange behaviour with spring boot when using @ConfigurationProperties on yaml files.
It seems that when i declare a pojo as follows and use config.yml to store my configuration settings
@ConfigurationProperties(location = 'config.yml', prefix='settings')
That my command line arguments are lower in precedence than the values inside the config.yml file. Reading the documentation i would expect that the Command line arguments are always higher.
However, when i declare a pojo as follows and use application.yml to store my configuration settings
@ConfigurationProperties(prefix='settings')
The command line arguments are higher in precedence.
Is that expected behaviour?
Github project (https://github.com/vcetinick/spring-boot-yaml-test)
I have written on stack overflow (http://stackoverflow.com/questions/35262664/spring-boot-configuration-behaviour-with-configurationproperties-and-command-li)
The text was updated successfully, but these errors were encountered: