zoukankan      html  css  js  c++  java
  • springcloud(Config)五

    1、在码云建个仓库,例如springcloud-config-fortest
    2、然后建一个application.yml,内容如下(为了测试访问例如http://localhost:3344/application-dev.yml)

    spring:
      profiles:
        active: dev
    ---
    spring:
      profiles: dev
      application:
        name: springcloud-config-dev
    ---
    spring:
      profiles: test
      application:
        name: springcloud-config-test
    

    image
    3、在idea新建一个maven项目,springcloud-config-server-3344

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-server</artifactId>
        <version>2.1.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    

    4、新建application.yml,内容如下,需要配置git仓库地址

    spring:
      cloud:
        config:
          server:
            git:
              uri: https://gitee.com/zhangpenga/springcloud-config-fortest.git
      application:
        name: springcloud-config-server
    server:
      port: 3344
    

    5、新建主启动类Config_Server_3344,添加config配置@EnableConfigServer
    image
    6、启动Config_Server_3344,

    • 访问http://localhost:3344/application-dev.yml
      image
    • 访问http://localhost:3344/application-test.yml
      image
      ///////////////////////////////////////////////
      application.yml就是仓库里的文件
      image
      其中dev和test分别代表仓库里的spring.profiles=dev
      ///////////////////////////////////////////////

    7、修改仓库里的application.yml,然后push到master,再次访问就是修改之后的文件。

  • 相关阅读:
    Windows环境下Unicode编程总结
    我的CS脚本autoexec.cfg
    完成端口与高性能服务器程序开发[引用]
    调用未知DLL中的导出函数
    兼容Vista 赛门铁克公测新杀毒软件
    I Love You的真正含义
    码根码
    木马经典十大藏身地点大搜查
    Windows调试器及不同平台符号包下载地址(收集)
    “千般路”与“磨豆腐”
  • 原文地址:https://www.cnblogs.com/kaka-qiqi/p/14711412.html
Copyright © 2011-2022 走看看