# 第 14 章 配置管理

本章介绍

* 运行 Spring Cloud Config Server
* 创建 Config Server 客户端
* 存储敏感配置信息
* 自动刷新配置信息

经历过买房子或汽车的人，一定会遇到过需要签很多字的麻烦。在进行重大采购时，往往要签订纸质合同。这时您就会发现，现实世界对无纸化办公其实一点都不感冒。每当我坐在桌旁，而对面是一个汽车经销商或产权代理人时，我觉得确实应该提前准备一些创可贴，因为我肯定会被那些大堆的合同纸割伤。

不过我也注意到，尽管我必须签名的这些合同的页数还是很多，但近年来，我不必像以前那样，需要在表格上填写那么多字段了。以前的表格大多都需要手工填写，而现在的表格在打印之前，通常是预先填充了提前收集的基本数据。这不仅使整个过程更快，而且还减少了由于手工复制数据而可能导致的错误。

同样，许多应用程序都有某种形式的配置。在第 5 章，我们讨论了通过设置属性来配置 Spring Boot 应用程序的方法。通常，您设置的属性对于应用程序可能是唯一的，并且很容易在 `application.properties` 或 `application.yml` 中指定。

然而，当应用程序采用微服务架构时，配置的属性通常在多个服务中是通用的。就像以前那样单调乏味的、重复手工填写表单很容易出错一样，重复配置多个相同服务可能会产生一些错误。

在本章中，我们将介绍 Spring Cloud Config Server，它是为给定应用中的所有服务，提供集中配置服务的。通过 Config Server，您可以在一个地方管理应用程序的所有配置，而不需要手工复制配置。

在开始之前，让我们简单地考虑一下，单独配置微服务的不足，以及集中式配置的优点。


---

# 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-14-zhang-pei-zhi-guan-li.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.
