没有合适的资源?快使用搜索试试~ 我知道了~
首页spring cloud中文版【Spring Cloud Config】--spring cloud中文文档.pdf
资源详情
资源评论
资源推荐

2017/2/22 springcloud中文版【SpringCloudConfig】springcloud中文文档
https://springcloud.cc/springcloudconfigzhcn.html 1/35
Spring Cloud Config
Table of Contents
关于(about)
贡献者(Contributor)
快速入门(Quick Start)
客户端示例(Client Side Usage)
配置服务(Spring Cloud Config Server)
资源库环境(Environment Repository)
健康指示器(Health Indicator)
安全(Security)
加密与解密(Encryption and Decryption)
密钥管理(Key Management)
创建一个测试密钥库(Creating a Key Store for Testing)
使用多密钥和循环密钥(Using Multiple Keys and Key Rotation)
加密属性服务(Serving Encrypted Properties)
可替换格式服务(Serving Alternative Formats)
文本解释服务(Serving Plain Text)
嵌入配置服务器(Embedding the Config Server)
推送通知和总线(Push Notifications and Spring Cloud Bus)
客户端配置(Spring Cloud Config Client)
配置第一次引导(Config First Bootstrap)
发现第一次引导(Discovery First Bootstrap)
Config Client Fail Fast
配置客户端重试(Config Client Retry)
定位远程配置资源(Locating Remote Configuration Resources)
安全(Security)
Vault
关于(about)
由于翻译质量不高,所以合成为中英对照双语版本,如有不当之处,可联系修正,感谢你的支持。
贡献者(Contributor)
木木彬(252971652@qq.com)
Andy.Ren(rcl026@163.com)

2017/2/22 springcloud中文版【SpringCloudConfig】springcloud中文文档
https://springcloud.cc/springcloudconfigzhcn.html 2/35
甘明(xyuu@xyuu.net)
Spring Cloud Config provides server and client-side support for externalized configuration
in a distributed system. With the Config Server you have a central place to manage
external properties for applications across all environments. The concepts on both client
and server map identically to the Spring Environment and PropertySource abstractions, so
they fit very well with Spring applications, but can be used with any application running
in any language. As an application moves through the deployment pipeline from dev to test
and into production you can manage the configuration between those environments and be
certain that applications have everything they need to run when they migrate. The default
implementation of the server storage backend uses git so it easily supports labelled
versions of configuration environments, as well as being accessible to a wide range of
tooling for managing the content. It is easy to add alternative implementations and plug
them in with Spring configuration.
快速入门(Quick Start)
Start the server:
The server is a Spring Boot application so you can run it from your IDE instead if you
prefer (the main class is ConfigServerApplication ). Then try out a client:
这个服务是一个Spring Boot应用,如果你喜欢你可以直接用IDE启动(main类
是 ConfigServerApplication ). 然后试着启动一个客户端:
The default strategy for locating property sources is to clone a git repository (at
spring.cloud.config.server.git.uri ) and use it to initialize a mini SpringApplication . The
mini-application’s Environment is used to enumerate property sources and publish them
via a JSON endpoint.
$ cd spring-cloud-config-server
$ ../mvnw spring-boot:run
$ curl localhost:8888/foo/development
{"name":"development","label":"master","propertySources":[
{"name":"https://github.com/scratches/config-repo/foo-development.properties","source":
{"bar":"spam"}},
{"name":"https://github.com/scratches/config-repo/foo.properties","source":{"foo":"bar"}}
]}

2017/2/22 springcloud中文版【SpringCloudConfig】springcloud中文文档
https://springcloud.cc/springcloudconfigzhcn.html 3/35
默认加载property资源的策略是克隆一个git仓库(at spring.cloud.config.server.git.uri'),用它去
初始化一个mini `SpringApplication , 这个mini SpringApplication 的 Environment 用来枚举
property,通过json节点发布它们.
The HTTP service has resources in the form:
HTTP服务资源的构成:
where the "application" is injected as the spring.config.name in the SpringApplication
(i.e. what is normally "application" in a regular Spring Boot app), "profile" is an active
profile (or comma-separated list of properties), and "label" is an optional git label
(defaults to "master".)
application是 SpringApplication 的 spring.config.name ,(一般来说'application'是一个常规的
Spring Boot应用),profile是一个active的profile(或者逗号分隔的属性列表),label是一个可选的
git标签(默认为"master").
Spring Cloud Config Server pulls configuration for remote clients from a git repository
(which must be provided):
Spring Cloud Config Server从git仓库为 为远程客户端拉取配置信息:
客户端示例(Client Side Usage)
To use these features in an application, just build it as a Spring Boot application that
depends on spring-cloud-config-client (e.g. see the test cases for the config-client, or
the sample app). The most convenient way to add the dependency is via a Spring Boot
starter org.springframework.cloud:spring-cloud-starter-config . There is also a parent pom
and BOM ( spring-cloud-starter-parent ) for Maven users and a Spring IO version management
properties file for Gradle and Spring CLI users. Example Maven configuration:
/{application}/{profile}[/{label}]
/{application}-{profile}.yml
/{label}/{application}-{profile}.yml
/{application}-{profile}.properties
/{label}/{application}-{profile}.properties
spring:
cloud:
config:
server:
git:
uri: https://github.com/spring-cloud-samples/config-repo
YAML

2017/2/22 springcloud中文版【SpringCloudConfig】springcloud中文文档
https://springcloud.cc/springcloudconfigzhcn.html 4/35
通过构建一个依赖spring-cloud-config-client(例如config-client的测试用例或者样例)的Spring
Boot应用,就可以使用这些特性.最方便的方法就是添加一个依赖 org.springframework.cloud:spring-
cloud-starter-config .对于Maven用户,有一个父pom和BOM( spring-cloud-starter-parent ),对于
Gradle和Spring CLI用户有一个Spring IO 版本管理文件.例如Maven的配置:
pom.xml
Then you can create a standard Spring Boot application, like this simple HTTP server:
然后你可以创建一个标准的Spring Boot应用,比如一个简单的HTTP服务:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Brixton.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<!-- repositories also needed for snapshots and milestones -->
XML

2017/2/22 springcloud中文版【SpringCloudConfig】springcloud中文文档
https://springcloud.cc/springcloudconfigzhcn.html 5/35
When it runs it will pick up the external configuration from the default local config
server on port 8888 if it is running. To modify the startup behaviour you can change the
location of the config server using bootstrap.properties (like application.properties but
for the bootstrap phase of an application context), e.g.
当它运行的时候,它将默认从本地配置服务器8888端口获取外部配置,你可以改版配置服务的位置通过
bootstrap.properties (类似于 application.properties ,但是是一个应用上下文启动的配置文件),例
如:
The bootstrap properties will show up in the /env endpoint as a high-priority property
source, e.g.
bootstrap.properties 将会在 /env 节点作为一个高优先级的property展示,例如:
(a property source called "configService:<URL of remote repository>/<file name>" contains
the property "foo" with value "bar" and is highest priority).
(一条叫做"configService:<URL of remote repository>/<file name>"的属性源包含了属性"foo"和
值"bar",它是最高优先级的)
@SpringBootApplication
@RestController
public class Application {
@RequestMapping("/")
public String home() {
return "Hello World!";
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
spring.cloud.config.uri: http://myconfigserver.com
$ curl localhost:8080/env
{
"profiles":[],
"configService:https://github.com/spring-cloud-samples/config-repo/bar.properties":{"foo":"bar"},
"servletContextInitParams":{},
"systemProperties":{...},
...
}
剩余34页未读,继续阅读

















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0