Skip to content

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

@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

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