-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Application properties outside of jar should take precedence over profile-specific variants inside the jar #3845
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
I do see the logic here but I'm still reluctant to change the default order for 1.3 as people may depend on it. @dsyer @wilkinsona Perhaps we could consider this change for Boot 2.0? |
Another uglier solution that might work for 1.2 would be to offer something like |
not in that format please (considering someone having an |
@philwebb Agreed on this being something we consider for 2.0 |
Why not make the load order configurable, for instance by adding a property spring.config.external-properties-overrides-embedded which can be set in an embedded property-file. Or, if it is too late to control load order once the properties are loaded, add a method on SpringApplication setExternalPropertiesOverridesInternal(boolean) which does the same thing? That way you can leave the default as is, but still give users the option to use the alternate load order if they prefer? |
As much as I'd like to include this in 1.3 it appears that it's not going to be a trivial change. I've made a start in https://github.com/philwebb/spring-boot/tree/gh-3845 by changing the load order in The problem is that regardless of the actual file load order, |
This would be a breaking change and something we can do in 3.0 |
The recent work in 2.4.x related to config file processing and profiles processes file such that application properties outside of the jar take precedence over profile-specific variants inside the jar. |
I'm quite disappointed that this feature has been introduced as a breaking change. As well I cannot follow the arguments here. Imagine a commons use case: you have a Prior 2.4, you could just throw that library into your microservices, and individually override specific properties at will. Now, you simply cannot override the common properties anymore in any way. Because |
@membersound Can you provide some more details about what you're trying to do? Perhaps a sample application would help? Are you saying that you have properties defined in |
I have a As far as I understood, it won't be possible to override the |
@membersound The scenario you describe should still work. The only thing that's a little unusual is putting If you're finding things aren't working as expected can you please open a new issue and provide a sample application that we can run and debug? |
I've opened #24688 to see if we can make it easier for common jars to contribute properties. |
The way I handled it so far was naming them eg The microservice can then load the properties (and also other defaults) by using That prevents having to use factories and post processors. And as far as I could see now, things are still working as before with spring 2.4.x. Anyways it would be great if a commons jar could simply throw in a |
In reference to #2404 which has been closed...
Spring Booot, being an opinionated framework, should try as hard as possible to adhere to established standards in the industry.
Any application can have three levels of property values: Global default values, Environment default values and Instance specific values.
Profiles, by definition, are Environment default values. They should always be overridden by any instance specific property.
As I see it, you might want to ship default values both for the global settings and for environment specific settings (ie PROD, TEST etc) embeded in the application.
But any instance specific setting should always override the two latter. And, usually, instance specific settings are deployed together with the application on the server.
So to force people to use application-PROD.properties when deploying a production instance and application-TEST on a test instance, is not only wrong, but also a cause of many headaches. I have just spent an hour trying to explain to an infrastructure guy why he must add some text to the properties file based on which profile is used. He did not get it!
So instead of
we should have
The text was updated successfully, but these errors were encountered: