-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Custom @Profile annotations not working on @Configuration classes [SPR-11808] #16428
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
Juergen Hoeller commented The use of custom profile annotations sounds fine to me and should indeed work in the larger Spring meta-annotation vision. That said, I'm afraid this hasn't been properly defined for We can turn this into a properly defined feature for Spring Framework 4.1 now, with a GA target in mid July. However, I'm afraid it's a bit late to roll this into the 4.0.x line or a further 3.2.x release at this point since both are at the end of their respective line already. We might do a 3.2.10 at some point but there is no plan for when or whether we'll do that one at all :-( Juergen |
Juergen Hoeller commented Actually, I need to take a step back on my comment above with respect to the state of the art: There has been a complete revision of profile annotation handling in the 4.0.x line, and using custom profile annotations is fully supported there already. As for 4.0 GA and in an even further refined variant in 4.0.3, your scenario should work just fine. Juergen |
Miguel A. Baldi Hörlle commented Ok. But why the attached project does not work when using any version from 4.0.0.RELEASE to 4.0.5.RELEASE? |
Rafael Senna commented I also tested here with 4.0.5.RELEASE and does not work. Should we reopen the issue? |
Juergen Hoeller commented Alright, so it seems we've been missing something in our isolated tests there. Generally speaking, In any case, I'll have another look. Juergen |
Marcelo Borges Ribeiro commented Same problem here. I'd appreciate any help. |
Juergen Hoeller commented After some local variations of the submitted sample app, it seems that the problem is simply the lack of Hope that helps, Juergen |
Miguel A. Baldi Hörlle commented Thank you very much, Juergen! |
Miguel A. Baldi Hörlle opened SPR-11808 and commented
Starting at version v3.2.2, custom
@Profile
annotations no longer work on@Configuration
classes.Before version 3.2.3, the above configuration works as expected,
MainConfiguration
only gets executed when profile "main" is activated.Unfortunately, when I upgraded to version 3.2.8, whenever I have a custom profile annotation on a
@Configuration
class, the active profiles are not honored.I've searched the documentation looking for some light on this, but with no luck.
Is this the expected behavior or a bug?
I've attached a sample application to demonstrate this behavior.
Will use version 3.2.2, and all tests must pass.
will use version 3.2.8, and tests shall fail.
I think I found the commits that changed this behavior, they are related to issue #15176. When I revert the commits related to that issue, everything works for me.
I have a large enterprise application that relies on that feature (custom
@Profiles
) and we need to upgrade Spring because of issues #15018 and #15726.Thanks!
Affects: 3.2.3, 3.2.8
Attachments:
Issue Links:
@Import
(ChildConfig) or EnclosingConfig.ChildConfig and then ChildConfig does not load beans on ParentConfig@Configuration
classes@Profiles
not mergedReferenced from: commits 5eecb13
4 votes, 8 watchers
The text was updated successfully, but these errors were encountered: