Although classified as regression and closed #13151 is still present.
Consider a application-e.yml
spring:
profiles:
include: dev
Starting the the application with
-Dspring.profiles.active=e
results in following console output in Spring Boot 2.0.2+:
The following profiles are active: e,dev
But I expect the right order to be
dev,e
because the current behaviour makes is virtually impossible to build up a profile hierarchy, as more specific profiles cannot overwrite properties of less specific profiles.
If current behaviour is not a bug, an explaination would be very helpful.
Thanks a lot.
Comment From: mbhave
@jruhe-adesso I wasn't able to reproduce this on Spring Boot 2.0.7. Can you provide a small sample that reproduces the behavior? We have a test that, if I understood correctly, tests this behavior.
Comment From: jruhe-adesso
Here is my example. Issue is specified in a single test class (2 of 3 tests fail) https://github.com/jruhe-adesso/issue15598.git
Thank you for your quick response.
Comment From: mbhave
Thanks for the sample. This is the expected behavior. In the sample, application-e.yml
has a spring.profile.include: dev
property. The property source loaded by the dev
profile has a higher precedence than the property source loaded by the e
profile which is why the value of my.property
is devValue
.
I'm going to close the issue as this is the expected behavior for profiles included in profile-specific files. If you have anymore questions please join us on Gitter or ask on StackOverflow.
Comment From: tspoeri
@mbhave could you please elaborate why this is the expected behavior? As @jruhe-adesso mentioned in the original post the behavior used to be different and makes it almost impossible to create a profile hierarchy. In the given example 'dev' is kind of a base profile with some default values and 'e' is the profile the application is launched with, so I would expect that the values of profile 'e' have higher precedence. If not, then I see no way to overwrite a value defined in the included base profile, or have I missed something?
Comment From: huehnerlady
Why is this issue closed, where is the current issue for this problem? Still have that problem with 2.2.7
It does not make sense that properties from included profiles override specified properties in current properties file.
How else do you include lets-say "dev-stage" and then say "oh but I want to use my local database not the dev-stage database"...
Many thanks
Comment From: wilkinsona
@huehnerlady There's no current issue as we believe that things are currently behaving as designed and documented. If you have a requirement that the current design does not meet, please open a new issue with a small sample that illustrates what you're trying to do.
Comment From: huehnerlady
@wilkinsona unless there is another property where I can enable the order of the included profiles, it is the same way as @jruhe-adesso explained.
But maybe from another point of view. It was mentioned that this is supposed to be expected behavior. But how can I achieve overriding included properties? This makes it really annoying to develop anything really, as I want to have my local developer profile, include properties from some stages and then override the properties I need to adapt, which I can't.
I always have to copy/paste everything - and I need to remember to check whether the default dev-properties changed in the meantime.
So please fix this. Happy to create a separate issue with a sample project if needed, but I find the description of @jruhe-adesso quite good here :)
Comment From: wilkinsona
@huehnerlady Yes, please. A separate issue with a sample project would be great. We'd like to be 100% sure that what we're looking at is exactly the same as what you're describing.