alibaba / alibaba/spring-cloud-alibaba
using spring-cloud-starter-dubbo, in some cases, multiple RegistryConfig instances appear in the spring container
- Dominant language
- Java
- Stars
- 29.2k
- Forks
- 8.5k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 12
Description
**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.
```java
@Autowired
private RegistryConfig registry;
```
causes an exception to:
```log
***************************
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 consumed
```
**To Reproduce**
Steps to reproduce the behavior:
1. using spring-cloud-starter-dubbo
2. set spring cloud discovery in bootstrap.yml
3. 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"
4.
```java
@Autowired
private RegistryConfig registry;
```
5. start application, see a error
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure with spring-cloud-starter-dubbo, discovery settings in bootstrap.yml, and a non-spring-cloud dubbo.registry.address in application.yml. Inspect DubboServiceRegistrationAutoConfiguration and DubboApiDocsAnnotationScanner, especially the named RegistryConfig beans. Done means the application no longer creates conflicting RegistryConfig instances and the RegistryConfig injection starts successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100