-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Allow @Qualifier to be used in composed annotations with attribute overrides [SPR-14058] #18630
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
Sam Brannen commented FYI: I have introduced a failing test case. See |
Juergen Hoeller commented The problem here is that the algorithm identifies such a composed autowiring+qualifier annotation as a custom qualifier annotation, with Aside from the entire algorithm not supporting merged annotations yet, we also have a conceptual conflict between the existing arrangement for custom qualifier types and a to-be-introduced model for custom text-based qualifiers, since both use the same meta annotation marker. We could identify qualifier types which are also marked as autowiring annotations, treating them specifically, but at this point the entire qualifier matching algorithm does not know about autowiring annotations at all... and arguably should preserve that characteristic. Also, at the moment, a custom qualifier type marked with So all in all, I wonder whether this is worth supporting in the first place. With method argument autowiring as in JUnit 5, having regular |
Sam Brannen commented Hi Juergen, Thanks for the detailed analysis and thorough write-up! I had also investigated a bit on my own and came to the conclusion that this feature would in the very least require a considerable rewrite of the qualifier lookup algorithm. But based on your input here, it actually seems like it's not even feasible. Regarding our support for method injection in JUnit 5 tests, your analysis is correct: we already support all necessary use cases via My original goal was to allow users to use a single annotation in JUnit 5 for autowiring dependencies from a Spring Long story, short: feel free to resolve this issue as Won't Fix if you deem that appropriate. Cheers! Sam |
Juergen Hoeller commented Alright, let's resolve it as Won't Fix then. The real goal is to get rid of the need for qualifiers in the first place :-) Seriously, in particular with generics-based matching and primary markers, there is hardly a need for qualifiers anymore. In recent years, I'm telling people that qualifiers are becoming a niche feature in the Spring world. Juergen |
Sam Brannen commented Agreed: case closed! ;) |
Sam Brannen opened SPR-14058 and commented
Status Quo
@Qualifier
currently cannot be used as a meta-annotation in composed annotations with attribute overrides configured via@AliasFor
.The reason is that Spring's official autowiring support does not function properly if
@Qualifier
is declared as a meta-annotation with the qualifier set to an empty string (e.g., when the user chooses not to specify a qualifier when using the composed annotation).Impetus
This feature would be beneficial for #18151 & #18628 and is, in general, an enabler for anyone who wishes to use
@Qualifier
with string-based qualifier values in composed annotations.Deliverables
@Qualifier
to be used as a meta-annotation in composed annotations with explicit attribute overrides for string-based qualifiers.Affects: 4.2 GA
Issue Links:
@Autowired
to be declared on parametersReferenced from: commits 3c18a45, e83e3ec
The text was updated successfully, but these errors were encountered: