springboot 整合 dubbo 踩坑笔记

由于工作使用的是HSF,所以最近就自己研究下学习dubbo框架,采用当前主流的spring boot 集成 dubbo,学习过程中遇到了几个问题,在此记录下,希望可以帮到同样遇到问题的你。

问题1.The bean ‘dubboConfigConfiguration.Single’ could not be registered. A bean with that name has already been defined and overriding is disabled.

Description:

The bean 'dubboConfigConfiguration.Single' could not be registered. A bean with that name has already been defined and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

问题1简单来说就是服务启动时bean的名字被定义了多个,而且不能被重写,解决方法其实在报错信息里面也给出了:
在这里插入图片描述
解决方案:
application.properties配置文件中添加以下配置

spring.main.allow-bean-definition-overriding=true

在这里插入图片描述

问题2.java.lang.NoClassDefFoundError: io/netty/bootstrap/ServerBootstrap

在这里插入图片描述
问题2报io/netty/bootstrap/ServerBootstrap这个类找不到,既然找不到类,那么我们就需要导入这个类对应的jar包依赖:

<!-- https://mvnrepository.com/artifact/io.netty/netty-all -->
<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
</dependency>

dubbo框架是属于RPC远程过程调用的一种,而PRC协议的通信又是依赖于netty框架,而netty又是基于Java的NIO实现的,所以我们需要导入io/netty包
在这里插入图片描述

问题3.java.lang.ClassNotFoundException: org.apache.curator.framework.CuratorFrameworkFactory

在这里插入图片描述
和问题2一样报类找不到,需要导入对应的pom依赖

<!-- https://mvnrepository.com/artifact/org.apache.curator/curator-recipes -->
<dependency>
    <groupId>org.apache.curator</groupId>
    <artifactId>curator-recipes</artifactId>
    <version>2.13.0</version>
</dependency>

我们本次集成dubbo使用的是官方推荐的zookeeper注册中心,而curator是Netflix公司开源的一套zookeeper客户端框架,解决了很多Zookeeper客户端非常底层的细节开发工作,包括连接重连、反复注册Watcher和NodeExistsException异常等等,所以我们需要导入org.apache.curator包
在这里插入图片描述
至此,duboo的坑便踩完了,重新启动服务,发现我们的服务正式启动成功并在zookeeper注册中心完成注册:

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值