最近刚开始接触dubbo,于是自己搭建了一个spring boot+dubbo 的项目,相关细节不是太熟悉,过程中遇到了几个问题,
直接说问题:错误如下
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userControllet': Unsatisfied dependency expressed through field 'userIntegration'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userIntegration' defined in file [E:\Documents\project\idea-git\dubbodemo\userdemo\user-service\target\classes\org\song\rpc\dubbo\integration\UserIntegration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanInitializationException: Failed to init remote service reference at filed bookResource in class org.song.rpc.dubbo.integration.UserIntegration; nested exception is java.lang.IllegalStateException: Failed to check the status of the service org.song.rpc.dubbo.resource.BookResource. No provider available for the service org.song.rpc.dubbo.resource.BookResource:1.0.0 from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-user&default.loadbalance=roundrobin&dubbo=2.8.4&interface=org.song.rpc.dubbo.resource.BookResource&methods=getAllBooks&pid=11760&revision=1.0.0&side=consumer×tamp=1503911603298&version=1.0.0 to the consumer 10.100.142.104 use dubbo version 2.8.4
项目目录结构
这里的userdemo和bookdemo相互是提供者和消费者,
只要启动无论哪一个,都会报错如上,springboot启动失败,这时候我将消费注释掉
// @Reference(version = "1.0.0", consumer = "defaultConsumer")
// private UserResource userResource;
//
// public List<UserDTO> getUsers(){
// return userResource.getAllUsers();
// }
启动就成功了,这时候再启动另一个,也成功了。
问题:
是不是缺少什么配置?让服务启动的时候,即使没有提供者也不会报错,等提供者启动完成然后在建立关系?
已经解决了,有个配置是
consumerConfig.setCheck(false);
false:如果没有提供者则忽略,
true:抛异常
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。