spring cloud 配置中心

spring配置中心的使用

  • 配置中心原理
    Spring Cloud Config为服务端和客户端提供了分布式系统的外部化配置支持。配置服务中心采用Git的方式存储配置文件,因此我们很容易部署修改,有助于对环境配置进行版本管理。

配置中心使用了git 管理,yml 配置文件上传到git 服务器上,便于版本管理。
开发人员直接在git 上修改。

  • 使用方式

    1. *本地配置文件启用配置中心
server:
  port: 8030

eureka:
  client:
    serviceUrl:
          defaultZone: http://localhost:8010/eureka/ #eureka服务注册地址

# git管理配置
spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/fengzp/config/ #git仓库地址
          searchPaths: demo* #搜索路径
#          username: username
#          password: password
  application:
    name: config-server
 2. 启动命令启用配置中心

使用命令启用配置中心

nohup java -jar /usr/local/spring-boot/service-${name}-1.0.0-SNAPSHOT.jar --logging.path=/usr/
local/spring-boot/  --spring.cloud.config.enabled=true --spring.cloud.bootstrap.name=http-remo
te-file--spring.config.location=http://10.200.141.107/bootstrap.main.yml,http://10.200.141.107
 &

环境中需要有一个spring 配置中心,启动的时候配置中心地址,配置的指向配置中心,配置中心从git 上读取配置

命令启动配置中心,程序先从配置中心读取配置,如果配置失败,读取本地配置

开发过程中保证 本地配置与配置中心配置一致

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值