SpringBoot中Dubbo配置多注册中心

SpringBoot中使用Dubbo时如果配置多个注册中心,因为多注册中心通常是相对于消费者而言,所以修改comsumer配置如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
#开启多注册中心配置
dubbo.config.multiple=true

#第一个注册中心,名字为registry1
dubbo.registries.registry1.protocol=zookeeper
dubbo.registries.registry1.address=192.168.10.21:2181,192.168.10.22:2181

#第二个注册中心,名字为registry2
dubbo.registries.registry2.protocol=zookeeper
dubbo.registries.registry2.address=192.168.20.21:2181,192.168.20.22:2181

#设置默认的注册中心
dubbo.registries.registry1.default=true

使用的时候:

1
2
@Reference(register="registry2")
private OrderService orderService;

这个registry也是可以接受数组的(也即可以多注册中心调用服务)。

------ 本文完 ------