Repository navigation
Problem when including spring profiles with logical operators #16303
Description
Activity
- addedstatus: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged
on Mar 25, 2019 Profile expressions (and negated profiles) get processed last, i.e. once we already know the profiles activated and included by the config files. If the YAML document that's activated by a profile expression itself contains a
spring.profiles.include, that doesn't get processed at the moment.We'd have to go over the config files again to look for documents matching the profiles included by the expression. Let's see if the rest of the team thinks this is something we should fix.
- addedfor: team-attentionAn issue we'd like other members of the team to reviewAn issue we'd like other members of the team to review
on Mar 26, 2019 Based on the complexity of the fix we can decide whether it should go in
2.1.xor2.2.x.- addedtype: bugA general bugA general bugand removedfor: team-attentionAn issue we'd like other members of the team to reviewAn issue we'd like other members of the team to reviewstatus: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged
on Mar 27, 2019 - addedfor: team-attentionAn issue we'd like other members of the team to reviewAn issue we'd like other members of the team to review
on Apr 5, 2019 - removedfor: team-attentionAn issue we'd like other members of the team to reviewAn issue we'd like other members of the team to review
on Apr 5, 2019 I have a fix for this here but this is turning out to get a bit complicated because of the way included profiles are supposed to be ordered. For example, look at the configuration below:
spring.profiles: a spring.profiles.include: c --- spring.profiles: a & b spring.profiles.include: d,e --- spring.profiles: d spring.profiles.include: f ---
Given that profiles
aandbare active, the above configuration will lead to a profile order ofa, c, b, d, e, f, whereas one might expect it to bea, c, b, d, f, e. There are a lot of corner cases when it comes to profiles specific files/YAML documents and include profiles. We need to take a step back and redefine the rules, which will lead to a possible overhaul of this part of the code. We can tackle this in2.3.xonce we have a better idea of what it should look like.- addedfor: team-attentionAn issue we'd like other members of the team to reviewAn issue we'd like other members of the team to review
on Jul 31, 2020 - removedfor: team-attentionAn issue we'd like other members of the team to reviewAn issue we'd like other members of the team to review
on Jul 31, 2020 - addedtheme: config-dataIssues related to the configuration themeIssues related to the configuration themeand removed
on Aug 5, 2020 Spring Boot 2.4 has overhauled config processing. See this blog post for details. Since the
spring.profiles.includeproperty won't be supported going forward you'll need to find a different way to do what you want.I would suggest using
@Profile("a & b")directly in your code or adding anEnvironmentPostProcessorto set new profiles based on the existing ones.I'm going to close this one for now, but if you find there's an obvious use-case that we're missing from the new code then please comment back here and we can have another look. We'll need a bit more background about what's driving the need for the
includeAandBprofile in the first place.- addedstatus: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applyand removedtheme: config-dataIssues related to the configuration themeIssues related to the configuration themetype: bugA general bugA general bug
on Oct 23, 2020
Spring Boot v2.1.3.RELEASE
I have an application.yml where I want to include profiles based on logical conditions on what profiles are active. I've attached my application.yml
When I run
I get
The following profiles are active: a,includeA,b,includeB
This seems inconsistent, I was expecting a,includeA,b,includeB,includeAandB or possible a,b if the includes were not supported.