简介:
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
andPropertySource
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.Spring Cloud Config为分布式系统中的外部化配置提供服务器和客户端支持。 使用Config Server,您可以集中管理所有环境中应用程序的外部属性。 客户端和服务器上的概念与Spring Environment和PropertySource抽象完全相同,因此它们非常适合Spring应用程序,但可以与以任何语言运行的任何应用程序一起使用。 当应用程序从开发人员迁移到测试人员并进入生产过程时,您可以管理这些环境之间的配置,并确保应用程序具备迁移时所需的一切。 服务器存储后端的默认实现使用git,因此它轻松支持配置环境的标记版本,并且可用于管理内容的各种工具。 添加替代实现并将其插入Spring配置很容易。
Features
Spring Cloud Config Server features:
- HTTP, resource-based API for external configuration (name-value pairs, or equivalent YAML content)
- Encrypt and decrypt property values (symmetric or asymmetric)
- Embeddable easily in a Spring Boot application using
@EnableConfigServer
Config Client features (for Spring applications):
- Bind to the Config Server and initialize Spring
Environment
with remote property sources- Encrypt and decrypt property values (symmetric or asymmetric)
特征
Spring Cloud Config Server功能:
HTTP,用于外部配置的基于资源的API(名称-值对,或等效的YAML内容)
加密和解密属性值(对称或非对称)
使用@EnableConfigServer可轻松嵌入到Spring Boot应用程序中
Config Client功能(用于Spring应用程序):
绑定到Config Server并使用远程属性源初始化Spring Environment
加密和解密属性值(对称或非对称)
环境准备:在自己GitHub上新建一个Repository作为config center;注册中心使用的consul
命名规范:lable 分支名
,application 应用名(自定)
,profile 如:dev、test、prod
- /{lable}/{application}-{profile}.yml
- /{application}-{profile}.yml
- /{application}/{profile}/{lable}
如:
Config Center Server
POM
<dependency>