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

"primary" bean definitions in child context should take preference over those in parent context [SPR-5871] #10541

Closed
spring-projects-issues opened this issue Jun 26, 2009 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Kenny MacLeod opened SPR-5871 and commented

In general terms, if you have two beans of type A, both defined as primary="true", and another bean configured to @Autowire a bean of type A, then this will fail, with:

| No unique bean of type [A] is defined: more than one 'primary' bean found among candidates: [...]

This is good. However, imagine now the situation where the first bean of type A is in a parent context, and the second bean of type A is in a child context, with both still marked as primary="true". If I have a bean in the child context which @Autowires a bean of type A, then it still fails, with the same error.

is it not logical to expect that the primary="true" bean in the child context to be selected in preference to the bean in the parent context, even though both are marked as primary="true"?


Affects: 2.5.6

Attachments:

1 votes, 1 watchers

@spring-projects-issues
Copy link
Collaborator Author

Kenny MacLeod commented

See attached test case

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Good idea! Finally adopted in 3.0 RC1.

Juergen

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) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants