Skip to content

@Autowired and @Resource = autowiring by type and autowiring by name? [SPR-3646] #8327

Closed
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions