Skip to content

Precedence of included profiles _still_ broken since 2.0.2 #15598

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

Closed
jruhe-adesso opened this issue Jan 2, 2019 · 8 comments
Closed

Precedence of included profiles _still_ broken since 2.0.2 #15598

jruhe-adesso opened this issue Jan 2, 2019 · 8 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@jruhe-adesso
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 2, 2019
@mbhave
Copy link
Contributor

mbhave commented Jan 2, 2019

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

@mbhave mbhave added the status: waiting-for-feedback We need additional information before we can continue label Jan 2, 2019
@jruhe-adesso
Copy link
Author

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.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 4, 2019
@mbhave
Copy link
Contributor

mbhave commented Jan 4, 2019

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.

@mbhave mbhave closed this as completed Jan 4, 2019
@mbhave mbhave added status: invalid An issue that we don't feel is valid and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Jan 4, 2019
@tspoeri
Copy link

tspoeri commented Jan 16, 2019

@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?

@huehnerlady
Copy link

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

@wilkinsona
Copy link
Member

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

@huehnerlady
Copy link

@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 :)

@wilkinsona wilkinsona added the for: team-attention An issue we'd like other members of the team to review label May 14, 2020
@wilkinsona
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

7 participants