zoukankan      html  css  js  c++  java
  • spring cloud config搭建说明例子(一)-简单示例

    服务端 ConfigServer

    pom.xml添加config jar

    		<dependency>
    			<groupId>org.springframework.cloud</groupId>
    			<artifactId>spring-cloud-config-server</artifactId>
    		</dependency>
    

    添加EnableConfigServer

    @EnableConfigServer
    public class ConfigServerApplication {
        public static void main(String[] args) {
            SpringApplication.run(ConfigServerApplication.class, args);
        }
    }
    

    application.yml

    server:
       port: ${PORT:8888}                                #配置工程端口号
    
    spring:
       application:
          name: common-config-server                     #设置该服务应用名称
       profiles:
          active: native                                 #设置读取为本地工程文件
       config:
          server:
             native:
                searchLocations: classpath:/config       #配置文件根目录,也就是XXX-dev.properties等的目录
    

    官网也用发发发发这个端口。

    配置文件

    config下新建配置文件:
    XXX-dev.properties
    XXX-test.properties

    客户端AppClient

    pom.xml

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

    bootstrap.properties配置

    spring.cloud.config.name=XXX
    spring.cloud.config.profile=dev
    #spring.cloud.config.profile=test
    spring.cloud.config.uri=http://localhost:8888/ # 只能配置一个,不能逗号分隔配置多个config
    

    参考资料:
    csdn blog

  • 相关阅读:
    UVa 1364
    一个无向图博弈游戏
    poj 2777 Count Color (线段树)
    UVA 1660
    JS中的caller属性
    “给在读研究生+未来要读研同学们的一封受益匪浅的信”(摘录+整合)
    用cmd重命名.htaccess
    java Scoket的c\s结构聊天室
    log4j详解
    检查文本文件编码的Java程序
  • 原文地址:https://www.cnblogs.com/ouyida3/p/9124588.html
Copyright © 2011-2022 走看看