dubbo异常:Failed to check the status of the service . No provider available for the service 解决

服务消费者调用报Failed to check the status of the service . No provider available for the service 这个问题 ,dubboadmin上边看服务正常启动 ,报错信息如下:
在这里插入图片描述

Exception in thread “main” org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘demoService’: FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.alibaba.dubbo.demo.DemoService. No provider available for the service com.alibaba.dubbo.demo.DemoService from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=demo-consumer&dubbo=2.5.3&interface=com.alibaba.dubbo.demo.DemoService&methods=sayHello&pid=98896&side=consumer&timestamp=1565446380941 to the consumer 192.168.0.107 use dubbo version 2.5.3
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:178)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:101)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1647)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1215)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:257)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1085)
at com.alibaba.dubbo.demo.Consumer.main(Consumer.java:10)
Caused by: java.lang.IllegalStateException: Failed to check the status of the service com.alibaba.dubbo.demo.DemoService. No provider available for the service com.alibaba.dubbo.demo.DemoService from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=demo-consumer&dubbo=2.5.3&interface=com.alibaba.dubbo.demo.DemoService&methods=sayHello&pid=98896&side=consumer&timestamp=1565446380941 to the consumer 192.168.0.107 use dubbo version 2.5.3
at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:420)
at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:300)
at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:138)
at com.alibaba.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:65)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:171)
… 7 more

Process finished with exit code 1
问题解析:
可能出错的地方:
1、
提供者的XML配置如下:

<!--声明需要暴露的服务接口 version是服务的版本号dubbo只找对应版本号的服务提供者进行调用 timeout 超时时间 超过时间过报错-->
<dubbo:service interface="com.alibaba.dubbo.demo.DemoService" ref="demoService" version="1.0" timeout="5000"/>

消费者的XML配置:

<dubbo:reference id="demoService"  interface="com.alibaba.dubbo.demo.DemoService" version="1.0"/>

经过反复查找原因终于锁定了生产者XML和消费者文件中的version=“1.0”

教训:如果生产者设定了服务的版本,消费者一定要提供相应的版本号;
如果生产者不设定了服务的版本,消费者一定不设置版本号;
两者必须保持一致;
2、如果pom.xml中dubbo去掉了spring的配置
pom.xml中加入spring-context对应的jar包
3、在网上有的说可能与服务提供者的@Service引入的jar包有关,经过本人测试,如果是使用xml的配置
加不加@Service这个注解不影响正常调用,即使加了@service注解,引入import org.springframework.stereotype.Service;或者import com.alibaba.dubbo.config.annotation.Service;不影响,都可以正常调用;
另外重写的方法加不加@Override注解也不影响

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值