Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 47cbf7f

Browse files
eureka 集群搭建
1 parent accbe51 commit 47cbf7f

File tree

44 files changed

+495
-94
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+495
-94
lines changed

‎.idea/compiler.xml‎

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/encodings.xml‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/workspace.xml‎

Lines changed: 82 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎cloud-consumer-order80/src/main/java/com/xzq/springcloud/config/ApplicationContextConfig.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.xzq.springcloud.config;
22

3+
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
34
import org.springframework.context.annotation.Bean;
45
import org.springframework.context.annotation.Configuration;
56
import org.springframework.web.client.RestTemplate;
@@ -14,6 +15,7 @@
1415
public class ApplicationContextConfig {
1516

1617
@Bean
18+
@LoadBalanced//开启负载均衡
1719
public RestTemplate getRestTemplate() {
1820
return new RestTemplate();
1921
}

‎cloud-consumer-order80/src/main/java/com/xzq/springcloud/controller/OrderController.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
@Slf4j
2020
public class OrderController {
2121

22-
private final static String PAYMENT_URL = "http://localhost:8001";
22+
// private final static String PAYMENT_URL = "http://localhost:8001";
23+
private final static String PAYMENT_URL = "http://CLOUD-PAYMENT-SERVICE";
2324

2425
@Autowired
2526
private RestTemplate restTemplate;

‎cloud-consumer-order80/src/main/resources/application.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ eureka:
1111
register-with-eureka: true #表示向注册中心注册自己 默认为true
1212
fetch-registry: true #是否从EurekaServer抓取已有的注册信息,默认为true,单节点无所谓,集群必须设置为true才能配合ribbon使用负载均衡
1313
service-url:
14-
defaultZone: http://localhost:7001/eureka/ # 入驻地址
14+
#defaultZone: http://localhost:7001/eureka/ # 入驻地址
15+
defaultZone: http://eureka7001.com:7001/eureka/, http://eureka7002.com:7002/eureka/ # 入驻地址

‎cloud-consumer-order80/target/classes/application.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ eureka:
1111
register-with-eureka: true #表示向注册中心注册自己 默认为true
1212
fetch-registry: true #是否从EurekaServer抓取已有的注册信息,默认为true,单节点无所谓,集群必须设置为true才能配合ribbon使用负载均衡
1313
service-url:
14-
defaultZone: http://localhost:7001/eureka/ # 入驻地址
14+
#defaultZone: http://localhost:7001/eureka/ # 入驻地址
15+
defaultZone: http://eureka7001.com:7001/eureka/, http://eureka7002.com:7002/eureka/ # 入驻地址
67 Bytes
Binary file not shown.
21 Bytes
Binary file not shown.

‎cloud-eureka-server7001/src/main/resources/application.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ server:
33

44
eureka:
55
instance:
6-
hostname: localhsot #eureka服务端实例名称
6+
hostname: eureka7001.com #eureka服务端实例名称
77
client:
88
register-with-eureka: false #表示不向注册中心注册自己
99
fetch-registry: false #false表示自己就是注册中心,我的职责就是维护服务实例,并不区检索服务
1010
service-url:
11-
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
11+
defaultZone: http://eureka7002.com:7002/eureka/ # 搭建集群
12+
# defaultZone: http://localhost:7001/eureka/ # 不搭建集群

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /