-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Restore support for spring.profiles.include for non profile specific documents #22944
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
Oh yes, please. Personally, I would prefer (For experience sake) I migrated one of our production apps to Spring Boot v2.4.0-M2 and now suddenly I need to maintain configuration groups for all of our environments in
I (somewhat) get this rationale but I (humbly) propose to make it an on-demand feature instead of enabling it by default ( P.S. |
@kedar-joshi Do you have any more details that you can share about how you currently use I've very much trying to keep the new code simpler and prevent some of the issues that we had with the earlier version. Although I was considering if we should add back some form of spring.config.activate.on-profile: !a
spring.profiles.include: b
prop1: value1
---
spring.config.activate.on-profile: b
spring.profiles.include: a;
prop2: value2 |
Sure. We use 1. Include + Active Profilesapplication.properties # Profile properties
spring.profiles.include = common
spring.profiles.active = ${PRODUCT_A_PROFILES:dev}
# e.g.
# PRODUCT_A_PROFILES = production,production-node-a
# Common application properties
# ... application-production.properties # Production environment specific properties
# ... application-production-node-a.properties # Node-A specific properties in production environment
# ... 2. (Only) Include Profilesapplication.properties # Profile properties
spring.profiles.include = ${PRODUCT_A_PROFILES:dev}
# e.g.
# PRODUCT_A_PROFILES = production-node-a
# Common application properties
# ... application-flavor-a.properties # Profile properties
spring.profiles.include = common
# Product flavor-a specific properties
# ... application-production.properties # Profile properties
spring.profiles.include = flavor-a
# Production environment specific properties
# ... application-production-node-a.properties # Profile properties
spring.profiles.include = production
# Node-A specific properties in production environment
# ... Value for Each method has its own denefits and challenges. Using On the other hand, Using We choose the method which best suits the product. |
Thanks very much for the extra information. I think option 1) wouldn't be too difficult for us to support since there are no Option 2) is more tricky since we'd be back to not knowing which profiles are active before we start to process the profile specific files. We can make option 2 look like option 1 if we do something like this: application.properties # Profile properties
spring.profiles.include = ${PRODUCT_A_PROFILES:dev}
spring.profiles.include=${production-node-a:dev}
spring.profiles.group.production-node-a=production
spring.profiles.group.production=flavor-a
spring.profiles.group.flavor-a=common
# Common application properties
# ... application-flavor-a.properties # Product flavor-a specific properties
# ... application-production.properties # Production environment specific properties
# ... application-production-node-a.properties # Node-A specific properties in production environment
# ... That's a obviously a bit more migration work, but it does allow us to determine exactly which profiles are active before we try to process profiles specific files/documents. |
See also the discussion in #21697 |
Luckily we haven't faced any such issue because of the way we define our configuration.
I understand how this is required from Spring Boot's perspective so I played around a bit. The results / observations were quite interesting. Group name being added before all other profiles was the biggest surprise. E.g. spring.profiles.group.production-node-a = production
spring.profiles.group.production = flavor-a
spring.profiles.group.flavor-a = common With above setup, This requires creation of pseudo group name (which doesn't have a profile file, just to make sure nothing gets accidentally overridden). Anyway, the biggest hurdle for us in adopting application.properties spring.profiles.active = common .. and set |
Also, I may have misinterpreted the scope / expectations of this issue. Your recent comment suggests that this issue is more about supporting However, I believe the argument that |
Maybe this is too specific to Spring Cloud Config, but there we leverage
Perhaps (likely) we are making a mess of this and I'd be happy to hear advice. And as mentioned this might be more a Spring Cloud concern, as really what we logically want to do here is just literally "include" common/shared properties but we end up having to use (abuse) the profile system to get there? I believe Spring Cloud Config does special processing on their end to "gather" included profiles from sources and return those dependent sources in the single request for property sources... so presumably they are affected by these changes in 2.4 although I haven't seen how they intend to adjust. Seems to be a similar problem to what is generally being solved here with discovering/ranking included profiles where that logic can theoretically chain infinitely and/or circularly. |
I've restored |
No description provided.
The text was updated successfully, but these errors were encountered: