Dubbo Spring Cloud 多注册中心支持

Nacos

依赖

1
2
3
4
5
<!-- Spring Cloud Nacos Service Discovery -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>

配置

  • bootstrap.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
spring:
cloud:
nacos:
username: test
password: test
discovery:
enabled: true
register-enabled: true
server-addr: 192.168.1.5:8848
context-path: /nacos
file-extension: yaml
group: dev/test/prod
namespace: appblog
timeout: 6000
ephemeral: false

# 消费方需配置
ribbon:
nacos:
enabled: true

Eureka

依赖

1
2
3
4
5
<!-- Eureka Service Discovery -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

配置

  • bootstrap.yaml
1
2
3
4
5
eureka:
client:
enabled: true
service-url:
defaultZone: http://127.0.0.1:8761/eureka/

Zookeeper

依赖

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
<!-- Zookeeper Service Discovery -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.12</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>${curator.version}</version>
</dependency>

配置

  • bootstrap.yaml
1
2
3
4
5
spring:
cloud:
zookeeper:
enabled: true
connect-string: 127.0.0.1:2181

Consul

依赖

1
2
3
4
5
6
<!-- Spring Cloud Consul Service Discovery -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
<version>${spring-cloud-consul.version}</version>
</dependency>

配置

  • bootstrap.yaml
1
2
3
4
5
6
spring:
cloud:
consul:
enabled: true
host: 127.0.0.1
port: 8500

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2021 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :