# 第 13 章 服务发现

本章介绍

* 微服务架构思考
* 创建服务注册中心
* 注册和发现服务

你看过电影《海底总动员》吗？在那部电影里，马林（Marlin，小丑鱼）的儿子尼莫（Nemo）失踪了。马林和多莉（Dory，蓝刺尾鱼）试图去澳大利亚悉尼寻找。一路上，他们遇到了一群月亮鱼。为了好玩，月亮鱼把自己排列成几种形状 ————剑鱼、章鱼，他们甚至为嘲笑马林，把自己打扮得也像一条小丑鱼。当多莉问他们是否知道怎么去悉尼时，他们排成了悉尼歌剧院的形状，然后变成一个箭头，指向东方的澳大利亚洋流。

虽然这部电影没有深入探讨月亮鱼的生活习性，但可以假设它们中的每一个，都是独立的个体。每个都有自己的鳞片、鳍、鳃、眼睛、内脏，甚至它们自己的希望和梦想。即使每个都是独立个体，但他们仍然一起排成有趣的形状，并帮助马林和多莉去澳大利亚。

本章是讨论微服务开发的第一章，这些微服务就像是月亮鱼那样。您将看到如何进行微服务开发，并使这些小型、独立的服务一起工作，以提供一个功能完整的应用程序。

更具体地说，您将看到如何使用一些有用的 Spring Cloud 组件，包括配置管理、容错管理，以及本章的主题————服务发现。在正式开始之前，让我们先快速了解一下什么是微服务，以及使用微服务所带来的好处。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://potoyang.gitbook.io/spring-in-action-v5/di-13-zhang-fu-wu-fa-xian.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
