-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
Support profile exclusivity and/or bean definition finality [SPR-7982] #12637
Comments
Chris Beams commented Thanks for the submission Neale. I'm slating this for 3.2, for a few reasons:
|
Dave Syer commented I think we can and should try and offer something here in 3.1. Surely we can |
Frank Scheffler commented I think providing boolean logic on profiles would also reduce the problem a bit, i.e. defining a profile dev and also providing means to apply configuration to "not" dev environments. Effectively, dev and prod are most likely to be exlusive OR. We often happen to have the same problem with secured/unsecured and the like. |
Chris Beams commented Frank, I've linked this issue to #13818 for reference. |
Neale Upstone commented Watching others use profiles in anger with 3.1, I'd really like to see this polished off in 3.2. Rather than my original proposal here, the override approach mentioned in the highly voted #10181 would solve the underlying problem, which is that beans can get overridden silently. Making overridding a bean something that has to be declared (even if just for XML - it's less of a problem with JavaConfig as we can use cleaner abstract class approaches to this), would resolve numerous issues around overridding beans. <bean id="bean1" ... />
<bean override="true" id="bean1" /> as the required approach to overriding beans, triggered by using the 3.2 XSD. This would then cause context initialisation to fail rather than silently succeed, if two incompatible profiles are activated together. Another thing which would be useful is if I got my finger out and did a presentation on how to split Spring projects into modules with configuration-by-contract between them (i.e. not just one single app context consuming all XML). Bad Spring XML-based library design is rather widespread in enterprise projects. |
Frank Scheffler commented I am still looking forward to having this feature for selectively providing alternate configurations within XML, e.g. dummy configurations used whenever a profile is NOT active, at all. |
Chris Beams commented Frank Scheffler, are you familiar with #13370? It introduced a |
Frank Scheffler commented No, I wasn't. Thanks for the hint, I will have a look at it. |
Juergen Hoeller commented This has largely been superseded by the generalized condition model in 4.0 (and by various refinements to the profile mechanism in 3.2 ahead of that). If there is anything to be desired still, please raise a focused issue against 4.3 / 5.0. |
Neale Upstone opened SPR-7982 and commented
There's a real opportunity to nail some corner cases with profiles, and conversely the risk of propagating some open-doors to bad practice.
Reading the example given at http://blog.springsource.com/2011/02/11/spring-framework-3-1-m1-released/, I can see a few areas I'd like to be explicit for fast failure:
I quite like the idea of allowing some combination of final and override as it would give expressiveness to developers intent.
<bean id='blah' override='true' ../>
would not only clearly denote that override was intended, but also allow validation that there was already a bean to override.Either of these suggestions would prevent the 'prod,dev' profile from being bootstrapped.
Examples would be:
Affects: 3.1 M1
Reference URL: http://blog.springsource.com/2011/02/11/spring-framework-3-1-m1-released/#comment-185086
Issue Links:
@Bean
(override=true) ("is duplicated by")@Bean
methods to override definitions in XML@Bean
method visibility6 votes, 12 watchers
The text was updated successfully, but these errors were encountered: