dubbo2.7.12 start with springboot export No registry config found or it's not a valid config! The registry config is: <dubbo:registry />
- Dominant language
- Java
- Stars
- 41.6k
- Forks
- 26.4k
- Avg merge
- 15h 13m
- Merged PRs (30d)
- 4
Description
- [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
- [ ] I have checked the [FAQ](https://github.com/apache/dubbo/blob/master/FAQ.md) of this repository and believe that this is not a duplicate.
### Environment
* Dubbo version: 2.7.12
* Operating System version: mac
* Java version: 1.8
### Steps to reproduce this issue
1. add spring-boot-starter-jdbc,spring-boot-devtools to pom
2. service start
Pls. provide [GitHub address] to reproduce this issue.
### Expected Result
service start success
### Actual Result
export ”No registry config found or it's not a valid config! The registry config is: “
### Reason
springboot启动时由于存在spring-boot-devtools自动装配会去判断装配条件
static class DevToolsDataSourceCondition extends SpringBootCondition implements ConfigurationCondition {
DevToolsDataSourceCondition() {
}
public ConfigurationPhase getConfigurationPhase() {
return ConfigurationPhase.REGISTER_BEAN;
}
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
Builder message = ConditionMessage.forCondition("DevTools DataSource Condition", new Object[0]);
String[] dataSourceBeanNames = context.getBeanFactory().getBeanNamesForType(DataSource.class);
if (dataSourceBeanNames.length != 1) {
return ConditionOutcome.noMatch(message.didNotFind("a single DataSource bean").atAll());
} else if (context.getBeanFactory().getBeanNamesForType(DataSourceProperties.class).length != 1) {
return ConditionOutcome.noMatch(message.didNotFind("a single DataSourceProperties bean").atAll());
} else {
BeanDefinition dataSourceDefinition = context.getRegistry().getBeanDefinition(dataSourceBeanNames[0]);
return dataSourceDefinition instanceof AnnotatedBeanDefinition && ((AnnotatedBeanDefinition)dataSourceDefinition).getFactoryMethodMetadata() != null && ((AnnotatedBeanDefinition)dataSourceDefinition).getFactoryMethodMetadata().getDeclaringClassName().startsWith(DataSourceAutoConfiguration.class.getPackage().getName() + ".DataSourceConfiguration$") ? ConditionOutcome.match(message.foundExactly("auto-configured DataSource")) : ConditionOutcome.noMatch(message.didNotFind("an auto-configured DataSource").atAll());
}
}
}
context.getBeanFactory().getBeanNamesForType(DataSource.class)这句代码导致RegistryConfig被初始化,但是DubboConfigEarlyInitializationPostProcessor还没有被加入,导致config.addIntoConfigManager()无法被调用,后续创建dubbo引用时由于ApplicaitonModel.getConfigManager().getRegistry(String id)获取不到RegistryConfig,导致报错
Contributor guide
Assessment
This issue has not been assessed yet.