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注册中心完成注册:
作者:努力就够了
来源链接:https://blog.csdn.net/weixin_43012300/article/details/107825755
版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。
2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。