不知道为什么消费者不能调用,报错如下:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ISerivceApi': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.cnepay.service.api.ISerivceApi. No provider available for the service com.cnepay.service.api.ISerivceApi from the url zookeeper://192.168.1.50:2181/com.alibaba.dubbo.registry.RegistryService?application=ConsumerMerchantService&dubbo=2.5.4-SNAPSHOT&interface=com.cnepay.service.api.ISerivceApi&methods=listSettles,listMerchants,getAuthorityMenu,login,getAllCurrentAmount,listTrans,getHomePageShow&pid=14132&side=consumer×tamp=1478084031098 to the consumer 192.168.4.133 use dubbo version 2.5.4-SNAPSHOT
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1590)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054)
at com.cnepay.test.Consumer.main(Consumer.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.IllegalStateException: Failed to check the status of the service com.cnepay.service.api.ISerivceApi. No provider available for the service com.cnepay.service.api.ISerivceApi from the url zookeeper://192.168.1.50:2181/com.alibaba.dubbo.registry.RegistryService?application=ConsumerMerchantService&dubbo=2.5.4-SNAPSHOT&interface=com.cnepay.service.api.ISerivceApi&methods=listSettles,listMerchants,getAuthorityMenu,login,getAllCurrentAmount,listTrans,getHomePageShow&pid=14132&side=consumer×tamp=1478084031098 to the consumer 192.168.4.133 use dubbo version 2.5.4-SNAPSHOT
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:168)
... 11 more
修改方法,在消费者配置文件引用服务的时候加上version
<dubbo:reference id="ISerivceApi" version="1.0.0" interface="com.cnepay.service.api.ISerivceApi" />
在这个version是在定义service的时候定义的,例如注解:
@Service(version = "1.0.0")
然后就好了