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

  • 相关阅读:
    P1865 A % B Problem
    P1198 [JSOI2008]最大数
    从英语学习写起,收获2013属于我的金秋
    Hadoop--有关Hadoop的启动
    android中文字高亮设置案例
    <Win32_16>来看看标准菜单和右键菜单的玩法
    jQuery 自学笔记—3
    【译】如何精确判断最终用户响应时间过长的原因?
    网络爬虫返回json处理数据
    2013--转变
  • 原文地址:https://www.cnblogs.com/mrchenzheng/p/12166233.html
Copyright © 2011-2022 走看看