ApplicationConfig.application == null

Springboot2.2.1 + Dubbo 2.6.5 整合时报错

 

Caused by: java.lang.IllegalStateException: ApplicationConfig.application == null
    at com.alibaba.dubbo.config.AbstractConfig.appendParameters(AbstractConfig.java:237) ~[dubbo-2.6.5.jar:2.6.5]
    at com.alibaba.dubbo.config.AbstractConfig.appendParameters(AbstractConfig.java:172) ~[dubbo-2.6.5.jar:2.6.5]
    at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:303) ~[dubbo-2.6.5.jar:2.6.5]
    at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:163) ~[dubbo-2.6.5.jar:2.6.5]
    at com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler.init(ReferenceAnnotationBeanPostProcessor.java:163) ~[dubbo-2.6.5.jar:2.6.5]
    at com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler.access$100(ReferenceAnnotationBeanPostProcessor.java:147) ~[dubbo-2.6.5.jar:2.6.5]
    at com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.buildInvocationHandler(ReferenceAnnotationBeanPostProcessor.java:141) ~[dubbo-2.6.5.jar:2.6.5]
    at com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.buildProxy(ReferenceAnnotationBeanPostProcessor.java:123) ~[dubbo-2.6.5.jar:2.6.5]
    at com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.doGetInjectedBean(ReferenceAnnotationBeanPostProcessor.java:117) ~[dubbo-2.6.5.jar:2.6.5]
    at com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.doGetInjectedBean(ReferenceAnnotationBeanPostProcessor.java:50) ~[dubbo-2.6.5.jar:2.6.5]
    at com.alibaba.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor.getInjectedObject(AnnotationInjectedBeanPostProcessor.java:340) ~[spring-context-support-1.0.2.jar:na]
    at com.alibaba.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor$AnnotatedFieldElement.inject(AnnotationInjectedBeanPostProcessor.java:520) ~[spring-context-support-1.0.2.jar:na]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at com.alibaba.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor.postProcessPropertyValues(AnnotationInjectedBeanPostProcessor.java:128) ~[spring-context-support-1.0.2.jar:na]
    ... 16 common frames omitted
Caused by: java.lang.IllegalStateException: ApplicationConfig.application == null
    at com.alibaba.dubbo.config.AbstractConfig.appendParameters(AbstractConfig.java:222) ~[dubbo-2.6.5.jar:2.6.5]
    ... 29 common frames omitted

 

原因是:  application.yml未配置 name

如下配置即可:

dubbo:
  application:
    id: dubbo-consumer-demo
    name: dubbo-consumer-demo
    logger: slf4j

ApplicationConfig.application == null