问题:
dubbo referenct 注入报错问题 ,我这个代码 之前 是可以跑的 时好时坏 (如果没记错的 话 我可能遗漏了 什么问题)
报错信息
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘consumerController’ defined in file [F:\workspace\com.jiajia.consumer\target\classes\com\jiajia\consumer\controller\ConsumerController.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanInitializationException: Failed to init remote service reference at filed userManager in class com.jiajia.consumer.controller.ConsumerController; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.jiajia.UserManager. No provider available for the service com.jiajia.UserManager from the url zookeeper://192.168.25.129:2181/com.alibaba.dubbo.registry.RegistryService?anyhost=true&application=dubboxdemo-web&check=false&dubbo=2.8.4&generic=false&interface=com.jiajia.UserManager&methods=getUsername&pid=14256&side=consumer×tamp=1555733090934 to the consumer 10.198.1.6 use dubbo version 2.8.4
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory1.getObject(AbstractBeanFactory.java:306)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)atorg.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)atorg.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)atorg.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)atorg.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)atorg.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)atorg.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)atjavax.servlet.GenericServlet.init(GenericServlet.java:160)atorg.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)atorg.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)atorg.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:865)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:136)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)atorg.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)atorg.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)atorg.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)atorg.apache.coyote.AbstractProtocolAbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpointSocketProcessor.run(JIoEndpoint.java:310)atjava.util.concurrent.ThreadPoolExecutor.runWorker(UnknownSource)atjava.util.concurrent.ThreadPoolExecutorWorker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanInitializationException: Failed to init remote service reference at filed userManager in class com.jiajia.consumer.controller.ConsumerController; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.jiajia.UserManager. No provider available for the service com.jiajia.UserManager from the url zookeeper://192.168.25.129:2181/com.alibaba.dubbo.registry.RegistryService?anyhost=true&application=dubboxdemo-web&check=false&dubbo=2.8.4&generic=false&interface=com.jiajia.UserManager&methods=getUsername&pid=14256&side=consumer×tamp=1555733090934 to the consumer 10.198.1.6 use dubbo version 2.8.4
at com.alibaba.dubbo.config.spring.AnnotationBean.postProcessBeforeInitialization(AnnotationBean.java:253)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
… 32 more
Caused by: java.lang.IllegalStateException: Failed to check the status of the service com.jiajia.UserManager. No provider available for the service com.jiajia.UserManager from the url zookeeper://192.168.25.129:2181/com.alibaba.dubbo.registry.RegistryService?anyhost=true&application=dubboxdemo-web&check=false&dubbo=2.8.4&generic=false&interface=com.jiajia.UserManager&methods=getUsername&pid=14256&side=consumer×tamp=1555733090934 to the consumer 10.198.1.6 use dubbo version 2.8.4
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:317)
at com.alibaba.dubbo.config.spring.AnnotationBean.postProcessBeforeInitialization(AnnotationBean.java:246)
… 35 more
我也有检查:
dubbo-admin 里 是有服务的提供者和消费者的 ,上图:
![dubbo reference 注入报错 dubbo reference 注入报错](/default/index/img?u=aHR0cHM6Ly9waWFuc2hlbi5jb20vaW1hZ2VzLzE1L2E1ZDgzMzMzNTFhYTViNDYyYzVkYzllMjcwYzM4NzI3LnBuZw==)
这是代码 :
![dubbo reference 注入报错 dubbo reference 注入报错](/default/index/img?u=aHR0cHM6Ly9waWFuc2hlbi5jb20vaW1hZ2VzLzc5OS8zNTdiMThkZjhmNzhmNDQ3NjU5MzEzYTk5MzM0ZmE2Ny5wbmc=)
![dubbo reference 注入报错 dubbo reference 注入报错](/default/index/img?u=aHR0cHM6Ly9waWFuc2hlbi5jb20vaW1hZ2VzLzk5Ny81MjkzZDAzZmJiYjQxNDVhZGFlNjY3N2EzNjQ2MzBjZC5wbmc=)
这个提供者的注解 是dubbo的
![dubbo reference 注入报错 dubbo reference 注入报错](/default/index/img?u=aHR0cHM6Ly9waWFuc2hlbi5jb20vaW1hZ2VzLzkwMC84YzMwNGNhODYwMmJiN2QxNDJiOTA4MThlYWNkNzE4NC5wbmc=)