开发者社区> 问答> 正文

springboot+dubbo 提供者 未启动 消费者 启动报错?报错

最近刚开始接触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&timestamp=1503911603298&version=1.0.0 to the consumer 10.100.142.104 use dubbo version 2.8.4


 

  • springboot 1.5.6
  • dubbo
  • zookeeper
  • mybatis+mysql  这个可以忽略

项目目录结构

 

这里的userdemo和bookdemo相互是提供者和消费者,

只要启动无论哪一个,都会报错如上,springboot启动失败,这时候我将消费注释掉

//    @Reference(version = "1.0.0", consumer = "defaultConsumer")
//    private UserResource userResource;
//
//    public List<UserDTO> getUsers(){
//        return userResource.getAllUsers();
//    }

启动就成功了,这时候再启动另一个,也成功了。

问题:

是不是缺少什么配置?让服务启动的时候,即使没有提供者也不会报错,等提供者启动完成然后在建立关系?

展开
收起
爱吃鱼的程序员 2020-06-08 11:24:33 950 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    已经解决了,有个配置是

    consumerConfig.setCheck(false);

    false:如果没有提供者则忽略,

    true:抛异常

     

    2020-06-08 11:24:50
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Dubbo开源现状与2.7规划 立即下载
Dubbo分布式服务治理实战 立即下载
《Dubbo 3.0 前瞻》 立即下载