using spring-cloud-starter-dubbo, in some cases, multiple RegistryConfig instances appear in the spring container
Author: KeRan213539Created Mar 29, 2021Updated Jul 21, 2026
Labelsarea/dubbo
Which Component spring-cloud-starter-dubbo
Describe the bug using spring-cloud-starter-dubbo, in some cases, multiple RegistryConfig instances appear in the spring container.
@Autowired
private RegistryConfig registry;causes an exception to:
***************************
APPLICATION FAILED TO START
***************************
Description:
Field registry in org.apache.dubbo.apidocs.core.DubboApiDocsAnnotationScanner required a single bean, but 2 were found:
- defaultSpringCloudRegistryConfig: defined by method 'defaultSpringCloudRegistryConfig' in class path resource [com/alibaba/cloud/dubbo/autoconfigure/DubboServiceRegistrationAutoConfiguration.class]
- org.apache.dubbo.config.RegistryConfig#0: defined in null
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumedTo Reproduce Steps to reproduce the behavior:
- using spring-cloud-starter-dubbo
- set spring cloud discovery in bootstrap.yml
- set `dubbo.registry.address' in application.yml, but the value not use "spring-cloud://localhost", instead, use others, such as "nacos://127.0.0.1:8848"
@Autowired
private RegistryConfig registry;- start application, see a error
Source: alibaba/spring-cloud-alibaba