您的位置:首页 > 编程语言 > Java开发

springcloud - config统一配置管理

2019-10-17 19:25 239 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/weixin_41997060/article/details/102613328

什么是统一配置管理

spring cloud config为分布式系统外部配置提供了服务器和客户端的支持,他包括config server和config client 两部分,由于config server和config client 都实现了对spring ervironment(环境)和property source(属性源)抽象映射,因此,spring cloudconfig非常适合spring应用程序,当然也可以与任何其他语言编写的应用程序配合使用

config server是一个可横向拓展,集中式的配置服务器,他用于集中管理应用程序各个环境下的配置,默认使用git存储配置内容.因此可以很方便的实现对配置的版本控制与内容审计.

config client 是config server的客户端,用于操作存储在config server中的配置属性.

为什么要统一配置管理

配置集中管理
不同环境不同配置
运行期间动态调整配置
自动刷新

架构图


代码实现

该项目(jwxt-config)必须也是eureka服务

  1. 在github上创建文件

2.pom.xml

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>

3.application.yml

spring:
application:
name: jwxt-config #指定服务名
cloud:
config:
label: master
server:
git:
uri: https://github.com/hanxuesong123/jwxt-config
username: 1323232302@qq.com
password: hanzhibin1
  1. 启动类
@EnableConfigServer

pom.xml

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>

application.xml

spring:
cloud:
config:
uri: http://localhost:8888
label: master
name: application-teacher
profile: dev
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: