apache / apache/dubbo-spring-boot-project
application.properties与dubbo.xml配置的兼容性问题
- Dominant language
- Java
- Stars
- 5.4k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
## 问题描述:
application.properties与dubbo.xml配置的兼容性问题。
dubbo.xml中reference或者service配置会影响application.properties中的config-center配置读取。
## 依赖版本:
基于dubbo-spring-boot-project 2.7.6 - 2.7.8 均存在该问题。
## 重现步骤:
在application.properties中做配置中心相关配置,配置内容如下:
```
dubbo.config-center.address=localhost:80
apollo.meta=localhost:80
dubbo.config-center.protocol=apollo
dubbo.config-center.namespace=arch.namespace
dubbo.config-center.parameters.config.namespace=arch.namespace
dubbo.config-center.parameters.config.group=arch.group
dubbo.config-center.cluster=qa
app.id=consumer-demo
```
在dubbo.xml中配置ReferenceBean,配置内容如下:
```
```
在springboot启动类中引入xml配置。
## 预期结果:
配置中心的配置内容(如namespace等)可以在ApolloDynamicConfiguration初始化的时候被读取到。

## 实际结果:
ApolloDynamicConfiguration在初始化的时候,参数url中的和配置中心相关的内容都是默认值,比如namespace=dubbo。

如果去掉xml中的 dubbo:reference声明,或者使用基于注解的Reference声明,都能得到预期的结果。
## 初步分析:
当前初步确认,直接原因是xml中的bean引发的加载时机问题,当xml中声明dubbo:reference或者dubbo:service,会导致更早的实例化,然后org.apache.dubbo.config.bootstrap.DubboBootstrap#startConfigCenter中发现configManager的实例中并没有事先加载的ConfigCenterConfig的实例,进入if逻辑再次重新加载的时候就会生成一个全部使用默认值的实例。
请教有没有比较好的解决方案。
## 代码示例
https://github.com/furaul/dubbo-spring-boot-project 的 master分支
使用org.apache.dubbo.spring.boot.sample.provider.bootstrap.DubboAutoConfigurationProviderBootstrap 启动示例。
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked sample repository and its DubboAutoConfigurationProviderBootstrap entry point, reproducing the case with application.properties and a dubbo.xml ReferenceBean. Trace org.apache.dubbo.config.bootstrap.DubboBootstrap#startConfigCenter and ConfigCenterConfig initialization, comparing XML-based and annotation-based references. Done means the Apollo configuration values are loaded before ApolloDynamicConfiguration initializes when XML declares a reference or service.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100