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,再次访问就是修改之后的文件。

  • 相关阅读:
    使用layui报错:Uncaught TypeError: Cannot create property 'LAY_TABLE_INDEX' on number '2
    mongodb安装教程
    PDF,Word,Markdown,HTML ,Doc文件格式的相互转换
    Go To Oracle
    spark、standalone集群 (2)集群zookeeper 热备
    spark、standalone集群 (1)
    tomcat8.0部署启动
    mysql5.7以上安装
    spark单击 搭建
    自定义标签
  • 原文地址:https://www.cnblogs.com/kaka-qiqi/p/14711412.html
Copyright © 2011-2022 走看看