Skip to content

Commit 1cdda8d

Browse files
author
duozhilin
committed
添加多版本支持例子注册中心使用zookeeper的说明
1 parent e0cef9b commit 1cdda8d

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

spring-cloud-mult-version-samples/README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
在使用多版本控制时,需要修改服务提供方和服务消费方,分别是application.yaml和pom.xml。
44

55
1、在服务提供方的application.yaml中添加versions属性,标明服务支持哪些版本。
6+
* eureka
67
```yaml
78
spring:
89
application:
@@ -20,8 +21,24 @@ eureka:
2021
metadata-map:
2122
versions: 1,2
2223
```
24+
* zookeeper
25+
```yaml
26+
spring:
27+
application:
28+
name: service-c
29+
cloud:
30+
zookeeper:
31+
connect-string: 127.0.0.1:2181
32+
discovery:
33+
register: true
34+
root: dev
35+
metadata:
36+
versions: 1,2
37+
server:
38+
port: 10101
39+
```
2340
24-
2、在服务消费方,只需要在pom.xml添加spring-cloud-starter-multi-version到pom.xml依赖中即可
41+
2、在服务消费方,只需要在pom.xml添加spring-cloud-starter-multi-version到pom.xml依赖中即可,eureka和zookeeper的依赖二选一。
2542
```xml
2643
<dependencies>
2744
<dependency>
@@ -32,10 +49,16 @@ eureka:
3249
<groupId>org.springframework.boot</groupId>
3350
<artifactId>spring-boot-starter-test</artifactId>
3451
</dependency>
52+
<!-- eureka作为注册中心时使用 -->
3553
<dependency>
3654
<groupId>org.springframework.cloud</groupId>
3755
<artifactId>spring-cloud-starter-eureka</artifactId>
3856
</dependency>
57+
<!-- zookeeper作为注册中心时使用 -->
58+
<dependency>
59+
<groupId>org.springframework.cloud</groupId>
60+
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
61+
</dependency>
3962
<dependency>
4063
<groupId>org.springframework.cloud</groupId>
4164
<artifactId>spring-cloud-starter-feign</artifactId>

0 commit comments

Comments
 (0)