-
Notifications
You must be signed in to change notification settings - Fork 38.4k
@Autowired and @Resource = autowiring by type and autowiring by name? [SPR-3646] #8327
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 You do have a point there. However, Note that We plan to extend
In other words, I'm keeping this issue open to track Spring 2.1 RC1's state of things in terms of Juergen |
Mark Fisher commented The The schema for Spring beans now supports <qualifier/> elements. They may contain 'type' and 'value' attributes as well as sub-elements to match against the qualifier annotation attributes (such as: <attribute name='..' value='..'/>). To review the official documentation of this new functionality (and more), please consult the latest version of the reference documentation (beginning with nightly snapshot #201). The primary coverage is in the section entitled "Fine-tuning annotation-based autowiring with qualifiers" within the "beans" chapter. Mark |
Henri Karapuu opened SPR-3646 and commented
The naming of
@Autowired
and@Resource
annotations does not make any sense.One autowires by type, other by name, but the annotation names do not reflect this in any way, and are even of completely different grammatical form.
My suggestion would be to add attribute to the
@Autowired
annotation, which would set the autowire type to 'name', 'type' or 'autodetect'. If the default would be 'type' then full backwards compatibility would maintained. This way those of us who don't care about commons annotations could use@Autowired
for everything, and have much cleaner looking code. Plus, we would get the added benefit of autodetecting the type.The
@Resource
could be kept as is for those who want to be compatible with commons annotations.No further details from SPR-3646
The text was updated successfully, but these errors were encountered: