Dubbo报错:no provider available for the service

在整合dubbo开发项目的时候,服务端能正常启动,启动web端的时候,控制台报错:no provider available for the service
这是个比较头疼的问题,控制台报错如下

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-05-25 11:37:47.560 ERROR 1208 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'doctorController': Injection of @org.apache.dubbo.config.annotation.Reference dependencies is failed; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.quliankeji.medicalcloud.iservice.doctor.IDoctorSV. No provider available for the service medicalcloud/com.quliankeji.medicalcloud.iservice.doctor.IDoctorSV from the url zookeeper://127.0.0.1:2181/org.apache.dubbo.registry.RegistryService?application=medicalcloud-consumer&default.timeout=20000&dubbo=2.0.2&group=medicalcloud&interface=com.quliankeji.medicalcloud.iservice.doctor.IDoctorSV&methods=getDoctorByCondition,getDoctorDetail&pid=1208&qos.enable=false&register.ip=192.168.0.103&release=2.7.0&side=consumer&timestamp=1558755467501 to the consumer 192.168.0.103 use dubbo version 2.7.0
	at org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor.postProcessPropertyValues(AnnotationInjectedBeanPostProcessor.java:132)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1416)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
	at com.quliankeji.medicalcloud.portal.PortalApplication.main(PortalApplication.java:16)
Caused by: java.lang.IllegalStateException: Failed to check the status of the service com.quliankeji.medicalcloud.iservice.doctor.IDoctorSV. No provider available for the service medicalcloud/com.quliankeji.medicalcloud.iservice.doctor.IDoctorSV from the url zookeeper://127.0.0.1:2181/org.apache.dubbo.registry.RegistryService?application=medicalcloud-consumer&default.timeout=20000&dubbo=2.0.2&group=medicalcloud&interface=com.quliankeji.medicalcloud.iservice.doctor.IDoctorSV&methods=getDoctorByCondition,getDoctorDetail&pid=1208&qos.enable=false&register.ip=192.168.0.103&release=2.7.0&side=consumer&timestamp=1558755467501 to the consumer 192.168.0.103 use dubbo version 2.7.0
	at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:393)
	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:301)
	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:225)
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler.init(ReferenceAnnotationBeanPostProcessor.java:162)
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler.access$100(ReferenceAnnotationBeanPostProcessor.java:146)
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.buildInvocationHandler(ReferenceAnnotationBeanPostProcessor.java:140)
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.buildProxy(ReferenceAnnotationBeanPostProcessor.java:122)
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.doGetInjectedBean(ReferenceAnnotationBeanPostProcessor.java:116)
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.doGetInjectedBean(ReferenceAnnotationBeanPostProcessor.java:49)
	at org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor.getInjectedObject(AnnotationInjectedBeanPostProcessor.java:340)
	at org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor$AnnotatedFieldElement.inject(AnnotationInjectedBeanPostProcessor.java:520)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
	at org.apache.dubbo.config.spring.beans.factory.annotation.AnnotationInjectedBeanPostProcessor.postProcessPropertyValues(AnnotationInjectedBeanPostProcessor.java:128)
	... 17 common frames omitted

选择重要的信息进行观察,Failed to check the status of the service com.quliankeji.medicalcloud.iservice.doctor.IDoctorSV,这里的意思就是这个Service接口创建失败,
后面的异常信息非常重要:No provider available for the service ,意思就是对于service来说,没有可实现的provider
消费者在访问提供者的时候失败了。

解决方案

Dubbo默认(缺省)会在启动时检查依赖的服务是否可用,不可用时会抛出异常,阻止Spring初始化完成,以便上线时,能及早发现问题,默认check=true
如果你的Spring容器是懒加载的,或者通过API编程延迟引用服务,请关闭check,否则服务临时不可用时,会抛出异常,拿到null引用,如果check=false,总是会返回引用,当服务恢复时,能自动连上。
可以通过check=”false”关闭检查,比如,测试时,有些服务不关心,或者出现了循环依赖,必须有一方先启动。

  1. 关闭某个服务的启动时检查

    <dubbo:reference interface=“com.taotao.ItemService” check=“false” />

  2. 关闭所有服务的启动时检查,

    <dubbo:consumer check=“false” />

  3. 关闭注册中心启动时检查:(注册订阅失败时报错)

    <dubbo:registry check=“false” />

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值