zoukankan      html  css  js  c++  java
  • SpringCloud学习笔记(5)——Config

    参考Spring Cloud官方文档第4~10章

    官网文档中所有示例中的配置都在git上

    https://github.com/spring-cloud-samples/config-repo

     

    Part II. Spring Cloud Config

    4. Quick Start

    查找属性资源的位置的默认策略是克隆一个git仓库,并且用它初始化一个最小的SpringApplication

    4.1 Client Side Usage

    程序运行的时候会抓取外部配置,默认从本地8888端口抓取本地配置。可以在bootstrap.properties文件中改变这种配置。bootstrap.properties是程序启动阶段的上下文,简单的说就是bootstrap.properties会先于application.properties文件在启动时被加载。

    5. Spring Cloud Config Server

    服务端提供HTTP通过资源API的方式来获取外部配置(键值对或者YAML格式的内容)。Spring Boot通过@EnableConfigServer内嵌了这种操作。

    5.1 Environment Repository

    Spring Boot加载配置的时候,"spring.cloud.name"等效于{application}, "spring.profiles.active"等效于{profile}

    仓库中,可以把配置文件存到子目录下,并且通过模式匹配来检索

    另外,在Git的URL路径中可以使用占位符,在搜索路径中也可以使用占位符。

    10. Spring Cloud Config Client
    10.1 Config First Bootstrap

    10.2 Discovery First Bootstrap

    10.5 Locating Remote Configuration Resources

    上代码

    这里需要三个工程:eureka-server-demo、config-server-demo、config-client-demo。第一个不用说,重点说下后面两个。

    首先,config-server-demo配置

    然后,config-client-demo配置

    分别启动这三个工程

    哈哈哈!成功!!!

    参考

    http://blog.csdn.net/qq_22841811/article/details/67637796

  • 相关阅读:
    PHP7 快速编译安装
    php访问url的四种方式
    php获取文件 return array数组的值
    thinkphp3.2自定义success及error跳转页面
    think php 访问时
    vtk点云数据的显示[转]
    strlen() 和 sizeof() 在字符串中的使用
    函数 MultiByteToWideChar() 详解
    函数WideCharToMultiByte() 详解
    wchar_t 和 char 之间转换
  • 原文地址:https://www.cnblogs.com/mrchenzheng/p/12166233.html
Copyright © 2011-2022 走看看