apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.39k stars 26.41k forks source link

dubbo2.7.12 start with springboot export No registry config found or it's not a valid config! The registry config is: <dubbo:registry /> #8487

Open opver opened 3 years ago

opver commented 3 years ago

Environment

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,导致报错

AlbumenJ commented 3 years ago

@kylixs PTAL

adonis2014 commented 1 year ago

2.7.3 升级到 2.7.18 也是报错 Caused by: java.lang.IllegalStateException: No registry config found or it's not a valid config! The registry config is: at org.apache.dubbo.config.AbstractInterfaceConfig.checkRegistry(AbstractInterfaceConfig.java:201) ~[dubbo-2.7.18.jar:2.7.18] at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:357) ~[dubbo-2.7.18.jar:2.7.18] at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:313) ~[dubbo-2.7.18.jar:2.7.18] at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:206) ~[dubbo-2.7.18.jar:2.7.18] at org.apache.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:68) ~[dubbo-2.7.18.jar:2.7.18] at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:171) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE] at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:101) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1818) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1266) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:260) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1510) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1467) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1250) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE

AlbumenJ commented 1 year ago

2.7.3 升级到 2.7.18 也是报错

这个在 3.1.1 中还有问题吗

adonis2014 commented 1 year ago

升级到 3.1.1 没问题

2.7.3 升级到 2.7.18 也是报错

这个在 3.1.1 中还有问题吗

a123434ww commented 1 year ago

现在用的duboo-2.7.18版本,启动时报Caused by: java.lang.IllegalStateException: No application config found or it's not a valid config! Please add to your spring config.,网上查了下原因说是jdk版本与dubbo版本不符导致,请问下jdk1.8环境下springboot集成dubbo+consul时,dubbo+consul目前用哪个版本比较稳定

AlbumenJ commented 1 year ago

现在用的duboo-2.7.18版本,启动时报Caused by: java.lang.IllegalStateException: No application config found or it's not a valid config! Please add to your spring config.,网上查了下原因说是jdk版本与dubbo版本不符导致,请问下jdk1.8环境下springboot集成dubbo+consul时,dubbo+consul目前用哪个版本比较稳定

<dependency>
  <groupId>org.apache.dubbo</groupId>
  <artifactId>dubbo</artifactId>
  <version>3.1.2</version>
</dependency>
<dependency>
  <groupId>org.apache.dubbo.extensions</groupId>
  <artifactId>dubbo-registry-consul</artifactId>
  <version>1.0.0</version>
</dependency>
a123434ww commented 1 year ago

现在用的duboo-2.7.18版本,启动时报Caused by: java.lang.IllegalStateException: No application config found or it's not a valid config! Please add to your spring config.,网上查了下原因说是jdk版本与dubbo版本不符导致,请问下jdk1.8环境下springboot集成dubbo+consul时,dubbo+consul目前用哪个版本比较稳定

<dependency>
  <groupId>org.apache.dubbo</groupId>
  <artifactId>dubbo</artifactId>
  <version>3.1.2</version>
</dependency>
<dependency>
  <groupId>org.apache.dubbo.extensions</groupId>
  <artifactId>dubbo-registry-consul</artifactId>
  <version>1.0.0</version>
</dependency>

你好,我们用2.x.x版本的话,dubbo+consul用哪个版本组合比较稳定啊

AlbumenJ commented 1 year ago

dubbo 2.7.18 + consul 4