Dubbo2.7使用Zookeeper注册中心

dubbo官方文档中关于集成zookeeper的说明在2.7.1版本下缺少了必要的步骤, 做此记录

环境

  • Dubbo 2.7.1
  • Zookpper 3.5.5
  • Springboot 2.1.1.RELEASE

Maven

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
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.5.5</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>

配置

1
2
3
4
5
6
7
8
9
10
11
# 服务端
dubbo:
application:
name: ${spring.application.name}
scan:
base-packages: test.dubbo
registry:
address: zookeeper://localhost:2181
protocol:
name: dubbo
port: 9999
1
2
3
4
5
6
7
8
# 客户端
dubbo:
application:
name: ${spring.application.name}
registry:
address: zookeeper://localhost:2181
protocol:
name: dubbo