springboot整合最新版dubbo以及dubbo-admin的安装
一、安装前准备
由于dubbo被阿里捐献给了apache,这次安装admin时,参考网上的资料,地址还是停留在之前的链接,踩了不少坑,这里记录下。
dubbo-admin下载地址:
地址一:https://github.com/apache/incubator-dubbo/releases
该地址2.6版本以上的包中没有dubbo-admin ,2.5x版本的有
地址二:https://github.com/apache/incubator-dubbo-ops
该地址中的dubbo-admin模块被单独拎出来了,springboot方式启动,可以直接运行main方法,或者使用 java -jar 方式启动,很方便,有github账号的可以fork一下,推荐使用这个版本,本文介绍的就是该版本 。
二、dubbo-spring-boot-starter的使用
github地址:https://github.com/alibaba/dubbo-spring-boot-starter 最新版本为2.0 ,本文也是使用的该版本。
2.1、添加依赖
1 2 3 4 5 |
|
2.2、新建接口模块
目录结构
接口类
1 2 3 4 5 6 7 8 9 |
|
2.3、新建provider模块
目录结构
接口实现类
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
配置文件
1 2 3 4 5 6 |
|
启动类
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
2.4、 消费者模块
目录结构
启动类
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
引用端
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
三、dubbo-admin的启动
下载地址二的包,直接在idea中打开,结构如下:
install完成之后,直接右键DubboAdminApplication Run
修改配置文件,位置在 dubbo-admin /src/main/resource下面
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
根据自己的需要修改,包括dubbo-admin用户名密码,当然zk的配置也是少不了的,具体怎么安装zk,启动以及配置,这里就不多说了,
默认的的用户名和密码为:
1 2 3 4 5 |
|
3.1、访问
localhost:7001
首页
service
provider
consumer
完整代码