搜索
您的当前位置:首页正文

SpringBoot 集成 Dubbo + zookeeper全注解方式(各种坑的说明)

来源:吉趣旅游网

        大家知道springBoot发明的初衷是为了减少xml的配置,而dubbo的传统方式就是xml配置,所以既然用了springBoot就应该遵循它的规则,在集成dubbo时改为全编程式注解的方式。下面我来为大家详细介绍集成的步骤:

一:安装zookeeper

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=C:/zookeeper-3.4.13/data
dataLogDir=C:/zookeeper-3.4.13/log

# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

完成以上步骤后就可以进入C:\zookeeper-3.4.13\bin 双击zkserver.cmd启动zookper。

二:创建服务提供者工程

       建议使用idea工具!!!我先是在本地磁盘建了一个文件夹springBoot-dubbo,然后选择File - open打开这个文件夹,接着在这个文件夹上创建model工程,如下图所示:

选择spring initializr

 选择Web,再选择Web复选框

4. 填写Project name,点击finish

5. 打开项目目录,删除以下文件夹和文件

如果相同的依赖太多,你也可以考虑创建pom父工程,统一依赖管理。

 1.服务者的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance

因篇幅问题不能全部显示,请点此查看更多更全内容

Top