SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

目录

 

1、准备

2、zookeeper配置

3、配置Dubbo服务端

4、配置Dubbo消费端

5、配置dubbo-admin查看服务端、消费端

6、启动查看效果

7、想看完整代码及工具直接运行 ???


1、准备

环境:window7、jdk1.8、tomact8.5.11、springboot1.5.14、zookeeper3.4.13

下载zookeeper:http://mirrors.shu.edu.cn/apache/zookeeper/zookeeper-3.4.13/

借用 http://start.spring.io/ 初始生成springboot客户端、服务端

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

2、zookeeper配置

在zookeeper-3.4.13conf目录下修改xxxxx.cfg文件,叫zoo.cfg

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

查看此文件,也可修改配置信息,主要修改路径及端口号,其他信息暂时不用

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

zookeeper的端口及数据存放目录

启动文件:

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

点击启动即可。

Dubbo、Dubbo、Dubbo、Dubbo、Dubbo、Dubbo、Dubbo、Dubbo、Dubbo、Dubbo

3、配置Dubbo服务端

目录结构:

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

POM.XML文件配置(截图为新增的):

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

在resources 下新增 providers.xml,内容如下:

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

application.properties下新增:server.port=8011

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

4、配置Dubbo消费端

目录结构:

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

POM.XML配置

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

consumers.xml配置:

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

Dubbo、Dubbo、Dubbo、Dubbo、Dubbo、Dubbo、Dubbo、Dubbo、Dubbo、Dubbo、Dubbo、Dubbo、

application.properties下新增:server.port=8012

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

5、配置dubbo-admin查看服务端、消费端

下载dubbo源码: https://github.com/alibaba/dubbo (没有的话,就百度找找咯)

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

找个tomcat8.5.11放在

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

顺便改下dubbo-admin-tomcat-8.5.11webappsROOTWEB-INFdubbo.properties 配置

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

6、启动查看效果

先启动 zookeeper bin 下 zkServer.cmd, 然后 dubbo-provider 、dubbo-consumer、dubbo-admin的 tomcat-8.5.11

dubbo-consumer 端调用:

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

dubbo-admin界面:

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

SpringBoot-Dubbo-服务-消费-zookeeper完整Demo

 

7、想看完整代码及工具直接运行 ???

百度网盘:链接:https://pan.baidu.com/s/11Jo9ECFymjfnELOsXNq-9A 密码:私信发邮箱

CSDN下载:https://download.csdn.net/download/ningyunyuyi/10557825