dubbo没有提供者 只有消费者 ,消费者显示没有提供者
刚刚学习java,错误百出,还没办法解决,昨天报了一个错误,
详细错误:
com.alibaba.dubbo.config.spring.AnnotationBean 2017-09-07 02:40:50 [DUBBO] Failed to init remote service reference at filed tbItemDubboService in class com.ego.manage.service.impl.TbItemServiceImpl, cause: Failed to check the status of the service com.ego.dubbo.service.TbItemDubboService. No provider available for the service com.ego.dubbo.service.TbItemDubboService from the url zookeeper://192.168.134.131:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-manage&dubbo=2.5.3&interface=com.ego.dubbo.service.TbItemDubboService&methods=updTbItem,show&pid=23968&revision=0.0.1-SNAPSHOT&side=consumer×tamp=1504766449832 to the consumer 192.168.2.63 use dubbo version 2.5.3, dubbo version: 2.5.3, current host: 192.168.2.63
java.lang.IllegalStateException: Failed to check the status of the service com.ego.dubbo.service.TbItemDubboService. No provider available for the service com.ego.dubbo.service.TbItemDubboService from the url zookeeper://192.168.134.131:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-manage&dubbo=2.5.3&interface=com.ego.dubbo.service.TbItemDubboService&methods=updTbItem,show&pid=23968&revision=0.0.1-SNAPSHOT&side=consumer×tamp=1504766449832 to the consumer 192.168.2.63 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.AnnotationBean.refer(AnnotationBean.java:302)
at com.alibaba.dubbo.config.spring.AnnotationBean.postProcessBeforeInitialization(AnnotationBean.java:233)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
,然后查看我的dubbo-admin界面,提供者没有任何服务,
消费者显示如下:
但是,查看我的dubbo.xml是有注册服务的,
好,说明我的服务没有注册到注册中心,那这个dubbo.xml可能没有被加载上,启动dubbo的代码是这样的
启动dubbo的话,显示正常,
在此,我不得不说,dubbo提供者方,真的很坑,如果你的dubbo.xml加载有错误的话,他是不会报错的,很坑。
我怀疑就是我的dubbo.xml没有被加载上,所以我就手动加载dubbo.xml,看报什么错误,Test代码修改为:
果然报错啦,喜大普奔。。。。
我截取了部分,意思就是找不到我的applicationContext.xml文件,查看地址,果然写错了
但是,我又发现一个问题,就是如果使用Main.main()这种启动dubbo的方法的话,dubbo.xml的路劲,必须是src/main/resource/META-INF/spring,很严格的,就是那么找的dubbo.xml,哭泣,所以我就把resource文件夹删掉啦。。。。。
这样的话,终于加载到了dubbo.xml,服务也有了。
我的服务:
提供者信息:
消费者信息:
菜鸟伤不起啊。。。