-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,58 @@ | ||
# 实现服务的注册与发现 | ||
|
||
|
||
本章节,我们将创建一个`micro-weather-eureka-client` 作为客户端,并演示如何让将自身向注册服务器进行注册,让其可以其他服务都调用。 | ||
|
||
## 开发环境 | ||
|
||
* Gradle 4.0 | ||
* Spring Boot 2.0.0.M3 | ||
* Spring Cloud Netflix Eureka Client Finchley.M2 | ||
|
||
|
||
## 更改配置 | ||
|
||
增加如下配置: | ||
|
||
```groovy | ||
dependencies { | ||
//... | ||
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client') | ||
//... | ||
} | ||
``` | ||
|
||
## 一个最简单的 Eureka Client | ||
|
||
```java | ||
@SpringBootApplication | ||
@EnableDiscoveryClient | ||
@RestController | ||
public class Application { | ||
|
||
@RequestMapping("/") | ||
public String home() { | ||
return "Hello world"; | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(Application.class, args); | ||
} | ||
} | ||
``` | ||
|
||
项目配置: | ||
|
||
``` | ||
spring.application.name: micro-weather-eureka-client | ||
eureka.client.serviceUrl.defaultZone: http://localhost:8761/eureka/ | ||
``` | ||
|
||
## 运行 | ||
|
||
分别在 8081 和 8082 上启动了客户端示例。可以在 Eureka Server 上看到这两个实体的信息。 | ||
|
||
![eurake-client](../../images/register-discover/eurake-client.jpg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1 @@ | ||
# 微服务的注册与发现 | ||
|
||
本章节,我们将创建一个`micro-weather-eureka-client` 作为客户端,并演示如何让将自身向注册服务器进行注册,让其可以其他服务都调用。 | ||
|
||
## 开发环境 | ||
|
||
* Gradle 4.0 | ||
* Spring Boot 2.0.0.M3 | ||
* Spring Cloud Netflix Eureka Client Finchley.M2 | ||
|
||
|
||
## 更改配置 | ||
|
||
增加如下配置: | ||
|
||
```groovy | ||
dependencies { | ||
//... | ||
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client') | ||
//... | ||
} | ||
``` | ||
|
||
## 一个最简单的 Eureka Client | ||
|
||
```java | ||
@SpringBootApplication | ||
@EnableDiscoveryClient | ||
@RestController | ||
public class Application { | ||
|
||
@RequestMapping("/") | ||
public String home() { | ||
return "Hello world"; | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(Application.class, args); | ||
} | ||
} | ||
``` | ||
|
||
项目配置: | ||
|
||
``` | ||
spring.application.name: micro-weather-eureka-client | ||
eureka.client.serviceUrl.defaultZone: http://localhost:8761/eureka/ | ||
``` | ||
|
||
## 运行 | ||
|
||
分别在 8081 和 8082 上启动了客户端示例。可以在 Eureka Server 上看到这两个实体的信息。 | ||
|
||
![eurake-client](../../images/register-discover/eurake-client.jpg) |