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
I defined three Services in my configuration:
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