zoukankan      html  css  js  c++  java
  • 1.分布式配置中心 spring-cloud-config

    pring Cloud 版本:2.1.0.RELEASE

    一、server端

    1.maven依赖

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

    2.配置文件

    注:application.yml

    eureka:
      client:
        serviceUrl:
          defaultZone: http://localhost:8080/eureka/
    server:
      port: 8888
    spring:
      application:
        name: module-config-server     #注册的服务名
      cloud:
        config:
          server:
            git:
              uri: https://github.com/XXX  #git地址
              search-paths: /config     #git下的路径
              username:   #git用户名
              password:   #git密码
    

    3.源码解析

     

    二、client端

    1.maven依赖

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

     2.配置文件

    注:bootstrap.yml,此时必须使用bootstrap.yml,优先级大于application.yml,可以在启动的时候去server端fetch配置文件的信息

    server:
      port: 8081
    eureka:
      instance:
        hostname: localhost
        appname: order
      client:
        service-url:
          defaultZone: http://localhost:8080/eureka/
    spring:
      application:
        name: order
      cloud:
        config:
          discovery:
            enabled: true
            service-id: module-config-server
        #  enabled: true 可以省略
          label: master
          profile: dev
        #  uri: http://localhost:8888/ 默认就是这个地址,可以省略,有service-id时,优先使用service-id
    
     
  • 相关阅读:
    命令行颜色换算器(基于python)
    VPS常用操作(自用)
    自动读取虚拟币ETC行情并语音提醒的小工具(mac OSX)
    nginx最基本操作
    一个平庸程序员的自白
    unity 2d游戏 按y坐标排序子对象
    开源输入法推荐
    unity插件,从一段文字中提取中文并去重
    考试总结(CE???)
    螺旋矩阵
  • 原文地址:https://www.cnblogs.com/Hleaves/p/10348126.html
Copyright © 2011-2022 走看看