5.SpringCloud学习(五)——Spring Cloud Config 配置中心

1.简介

1.1 概述

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.

Spring Cloud Config 为分布式系统中的外部化配置提供服务器和客户端支持。使用Config Server,您可以集中管理所有环境中应用程序的外部属性。客户端和服务器上的概念与Spring Environment和PropertySource抽象完全相同,因此它们非常适合Spring应用程序,但可以与以任何语言运行的任何应用程序一起使用。当应用程序从开发人员迁移到测试人员并进入生产过程时,您可以管理这些环境之间的配置,并确保应用程序具有迁移时所需的一切。服务器存储后端的默认实现使用git,因此它可以轻松支持配置环境的标记版本,并且可以通过各种工具来访问这些内容来管理内容。添加替代实现并将其插入Spring配置很容易。

1.2 特点

  • HTTP, resource-based API for external configuration (name-value pairs, or equivalent YAML content): HTTP, 用于外部配置的基于资源的API(键值对,或等效的YAML内容)

  • Encrypt and decrypt property values (symmetric or asymmetric): 加密和解密属性值(对称或非对称)

  • Embeddable easily in a Spring Boot application using @EnableConfigServer Config Client features (for Spring applications): 使用 @EnableConfigServer Config Client功能(适用于Spring应用程序),可轻松集成到Spring Boot应用程序中

  • Bind to the Config Server and initialize Spring Environment with remote property sources: 绑定到Config Server并使用远程属性源初始化Spring `Environment

2.演示环境

  1. JDK 1.8.0_201
  2. Spring Boot 2.2.0.RELEASE、Spring Cloud Hoxton.RELEASE
  3. 构建工具(apache maven 3.6.3)
  4. 开发工具(IntelliJ IDEA )

3.演示代码

image-20200822214521079

总体结构说明:spring cloud config 简单使用

  • ofc-config-server: config 服务端,负责配置管理
  • ofc-config-client: config 客户端,获取服务端配置

3.1 ofc-config-server

3.1.1 代码说明

使用 spring-cloud-starter-config-server 开启配置管理服务端

3.1.2 maven 依赖

pom.xml

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-bo
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值