File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
spring-cloud-mult-version-samples Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 3
3
在使用多版本控制时,需要修改服务提供方和服务消费方,分别是application.yaml和pom.xml。
4
4
5
5
1、在服务提供方的application.yaml中添加versions属性,标明服务支持哪些版本。
6
+ * eureka
6
7
``` yaml
7
8
spring :
8
9
application :
@@ -20,8 +21,24 @@ eureka:
20
21
metadata-map :
21
22
versions : 1,2
22
23
` ` `
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
+ ` ` `
23
40
24
- 2、在服务消费方,只需要在pom.xml添加spring-cloud-starter-multi-version到pom.xml依赖中即可
41
+ 2、在服务消费方,只需要在pom.xml添加spring-cloud-starter-multi-version到pom.xml依赖中即可,eureka和zookeeper的依赖二选一。
25
42
` ` ` xml
26
43
<dependencies>
27
44
<dependency>
@@ -32,10 +49,16 @@ eureka:
32
49
<groupId>org.springframework.boot</groupId>
33
50
<artifactId>spring-boot-starter-test</artifactId>
34
51
</dependency>
52
+ <!-- eureka作为注册中心时使用 -->
35
53
<dependency>
36
54
<groupId>org.springframework.cloud</groupId>
37
55
<artifactId>spring-cloud-starter-eureka</artifactId>
38
56
</dependency>
57
+ <!-- zookeeper作为注册中心时使用 -->
58
+ <dependency>
59
+ <groupId>org.springframework.cloud</groupId>
60
+ <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
61
+ </dependency>
39
62
<dependency>
40
63
<groupId>org.springframework.cloud</groupId>
41
64
<artifactId>spring-cloud-starter-feign</artifactId>
You can’t perform that action at this time.
0 commit comments