apache / dubbo

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

Error creating bean with name 'eurekaClientConfigBean' #3891

Closed logyou closed 5 years ago

logyou commented 5 years ago

开发环境

引用包

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    <version>2.1.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.apache.dubbo</groupId>
    <artifactId>dubbo-spring-boot-starter</artifactId>
    <version>2.7.1</version>
</dependency>

问题描述

Spring Boot 项目,使用 Dubbo 和 Eureka ,启动项目时报错。

报错信息

2019-04-18 23:49:30.136  WARN 10140 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eurekaClientConfigBean': Unsatisfied dependency expressed through field 'propertyResolver'; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.core.env.PropertyResolver' available: expected single matching bean but found 2: dubboScanBasePackagesPropertyResolver,environment
2019-04-18 23:49:30.137  INFO 10140 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
2019-04-18 23:49:30.139  INFO 10140 --- [           main] f.a.ReferenceAnnotationBeanPostProcessor : org.apache.dubbo.common.bytecode.proxy0@2eada095 was destroying!
2019-04-18 23:49:30.139  INFO 10140 --- [           main] f.a.ReferenceAnnotationBeanPostProcessor : class org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor was destroying!
2019-04-18 23:49:30.140  INFO 10140 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2019-04-18 23:49:30.154  INFO 10140 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-04-18 23:49:30.155  INFO 10140 --- [           main] .b.c.e.AwaitingNonWebApplicationListener :  [Dubbo] Current Spring Boot Application is about to shutdown...
2019-04-18 23:49:30.159 ERROR 10140 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field propertyResolver in org.springframework.cloud.netflix.eureka.EurekaClientConfigBean required a single bean, but 2 were found:
    - dubboScanBasePackagesPropertyResolver: defined by method 'dubboScanBasePackagesPropertyResolver' in class path resource [org/apache/dubbo/spring/boot/autoconfigure/DubboRelaxedBinding2AutoConfiguration.class]
    - environment: a programmatically registered singleton

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

Process finished with exit code 1

是哪里的问题呢?如何解决?

luryson commented 5 years ago

@logyou 我也遇到这个问题,请问怎么解决的?