Skip to content
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

Field name is used to match on bean name when @Autowired matches several beans by type [SPR-16142] #20690

Closed
spring-projects-issues opened this issue Nov 1, 2017 · 3 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: task A general task
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Nov 1, 2017

Rasmus Lund opened SPR-16142 and commented

As shown by the referenced example project, field name is used to match on bean name when @Autowired matches several beans by type. We can't find this behavior documented anywhere. Is it by accident or by purpose? If by purpose, it should be mentioned in the reference documentation when @Autowired is described.

Note: The example project referenced by the URL shows a minimal setup that illustrates the unexpected behavior. It also has a more verbose explanation in its README.md.


Reference URL: https://github.com/mkjensen/spring-question

Issue Links:

Backported to: 4.3.13

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

This is indeed by design. I'll make sure to mention this properly in the documentation.

@spring-projects-issues
Copy link
Collaborator Author

Rasmus Lund commented

Thanks for the quick answer!

This has been a cause for big confusion on our project - so maybe mention in both ref-documentation and JavaDoc on @Autowired :-)

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Nov 7, 2017

Yanming Zhou commented

It very useful improvement, solved parts of #18201

@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches in: core Issues in core modules (aop, beans, core, context, expression) type: task A general task labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 5.0.2 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: task A general task
Projects
None yet
Development

No branches or pull requests

2 participants