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
    
     
  • 相关阅读:
    Visual Studio 常用快捷键 (二)
    Visual Studio 常用快捷键
    页游体验
    JSFL 工具
    GhostCat工具
    如何制作一个塔防游戏
    水墨
    给 想转2dx 却无从下手的aser
    两岸三地在线编程学习网站大全
    as3反射应用及简要代码
  • 原文地址:https://www.cnblogs.com/Hleaves/p/10348126.html
Copyright © 2011-2022 走看看