项目中准备使用Dubbo,运行官方的Provider和Consumer没有问题,自己写了个简单的SayHello进行测试,生产者启动后,通过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 cn.feezu.carsearch.service.DemoService. No provider available for the service cn.feezu.carsearch.service.DemoService from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=consumer-of-helloworld-app&default.timeout=5000&dubbo=2.5.3&interface=cn.feezu.carsearch.service.DemoService&methods=sayHello&pid=8148&side=consumer×tamp=1440572169099 to the consumer 10.10.8.101 use dubbo version 2.5.3 at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:151) at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103) at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1514) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:252) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:973) at Main.main(Main.java:15) Caused by: java.lang.IllegalStateException: Failed to check the status of the service cn.feezu.carsearch.service.DemoService. No provider available for the service cn.feezu.carsearch.service.DemoService from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=consumer-of-helloworld-app&default.timeout=5000&dubbo=2.5.3&interface=cn.feezu.carsearch.service.DemoService&methods=sayHello&pid=8148&side=consumer×tamp=1440572169099 to the consumer 10.10.8.101 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:144) ... 6 more
生产者的XML配置如下:
<?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd "> <dubbo:application name="hello-world-app" /> <!--zookeeper注册中心 --> <dubbo:registry address="zookeeper://127.0.0.1:2181" /> <!--使用multicast广播注册中心暴露服务地址 --> <!-- <dubbo:registry address="multicast://10.10.8.101:20881" /> --> <dubbo:protocol name="dubbo" port="20881" /> <dubbo:service interface="cn.feezu.carsearch.service.DemoService" ref="demoService" version="1.0" /> <!-- 和本地bean一样实现服务 --> <bean id="demoService" class="cn.feezu.carsearch.serviceImpl.DemoServiceImpl" /> </beans>
消费者的XML配置如下:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> <!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 --> <dubbo:application name="consumer-of-helloworld-app" /> <!--zookeeper注册中心 --> <dubbo:registry address="zookeeper://127.0.0.1:2181" /> <dubbo:consumer timeout="5000"/> <!-- 生成远程服务代理,可以和本地bean一样使用demoService --> <dubbo:reference id="demoService" interface="cn.feezu.carsearch.service.DemoService" /> </beans>
经过反复查找原因终于锁定了生产者XML文件中的version="1.0"
教训:如果生产者设定了服务的版本,消费者一定要提供相应的版本号(或空或写入对应的版本号)
如果有朋友不是这个问题,建议看看防火墙,有也在Dubbo的社区也问题过类似问题,梁飞的回复可能是防火墙的问题,建议关掉试下。
相关推荐
本项目案例“妻子”作为消费者去调用生产者(“丈夫”)的服务--洗碗 本项目需要注意 @DubboReference private HusbandService husbandService; @EnableDubbo @DubboService 这几个注解不能忘,否则会报错,或者...
dubbo消费者的web应用实例
dubbo提供者消费者例子,帮助理解dubbo的代码中的运用
1.dubbo-zookeeper springSpringMVC 一个生产者,多消费者 例子 2. ssm-dubbo 源码 ssm-tomcat 里放的是 warbao ,程序包 zookeeper-3.4.9 zookeeper 免安装包 设置都是默认的 zookeeper 端口 2181 dubbo-...
dubbo2.4版本提供者provider消费者consumerjar包
dubbo提供者和消费者工程
dubbo配置文件报红叉错误解决方案-dubbo.xsd 具体步骤见包里相关txt。
dubbo提供者和消费者示例
Dubbo服务提供者以及消费者实例
dubbo例子,里面有基于zookeeper的注册中心,提供者和消费者
dubbo实现的服务消费者,服务提供者,分模块拆分的demo
Dubbo生产者消费者示例源代码,Eclipse项目,基于Maven构建,可以直接导入Eclipse开发环境,本人亲测,编译通过,可以直接在Eclipse中运行(包含Main方法),先运行提供者,再运行生产者。
资料总结linux下 zookkeeper 查看dubbo消费者生产者.txt
学习地址http://blog.csdn.net/u012385190/article/details/52785520
基于注解、SpringBoot的Dubbo提供者消费者DEMO,下载下来直接可以跑。
- schema_reference.4: Failed to read schema document 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root ...
dubbo-provider-consumer生产者消费者实例 博文请查看:http://www.cnblogs.com/shawWey/p/6927141.html
1.SpringBoot聚合工程整合Dubbo,实现服务提供者与服务消费者的数据调用, 2.该项目提高了自己对Spring Boot整合Dubbo的理解,并深刻的认识到了服务者与消费者之间的调用及流程 4. Dubbo配置全部采用yml文件配置,...
解决dubbo启动报错,加载失败问题。
springboot融合dubbo 提供者消费者 协议api,provider 使用他提供服务,consumer使用他调用服务,实现代码 参考:https://download.csdn.net/download/itexplorersfather/10346699