-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed as duplicate
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by anothertype: bugA general bugA general bug
Description
I defined three Services in my configuration:
@Bean(value = "legacyContentService", defaultCandidate = false)
@Scope(value = BeanDefinition.SCOPE_SINGLETON, proxyMode = ScopedProxyMode.INTERFACES)
public ContentService legacyContentService() {
....
}
@Bean(value = "contentService", defaultCandidate = false)
@Scope(value = BeanDefinition.SCOPE_SINGLETON, proxyMode = ScopedProxyMode.INTERFACES)
public ContentService contentService() {
....
}
@Bean(value = "contentServiceDispatcher")
@Scope(value = BeanDefinition.SCOPE_SINGLETON, proxyMode = ScopedProxyMode.INTERFACES)
public ContentService contentServiceDispatcher(@Qualifier("legacyContentService") final ContentService legacyContentService, @Qualifier("contentService") ContentService contentService) {
return new ContentServiceDispatcher(legacyContentService, contentService);
}
But this lead to an unexpected exception: "no qualifiing bean of type ...ContentSerivce", "expected single matching bean but found 3". So "defaultCandidate = false" does not apply.
Then I removed "proxyMode = ScopeProxyMode.INTERFACES" from the @Scope-Annotations and then it worked. So I took a look at the Creation of the BeanDefinition of scoped beans.
I found, that ScopedProxyUtils#createScopedProxy does not consider the property "defaultCandidate". This property should also be applied to the scoped proxy bean definition.
Found in Spring-aop 6.2.x
I added a PR as proposal: #35627
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by anothertype: bugA general bugA general bug