一、配置文件服务器server端

1、构建server端所需jar

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
<version>1.4.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

2、构建server端main方法所在类的注解

@SpringBootApplication
@EnableConfigServer
@EnableEurekaClient
@EnableAutoConfiguration
@Configuration

3、构建server端所需配置文件及详解

server:
port: 8001
spring:
application:
name: spring-cloud-config-server
cloud:
config:
server:
git:
uri: https://github.com/Pinshuducha/config-file/ --git仓库地址
search-paths: config-repo --将拉取到的配置文件放到哪个文件夹下
username: --git用户名 有时可以不加
password: --git密码 有时可以不加
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8000/eureka/

二、配置文件服务器client端

1、构建client端所需jar

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
<version>1.4.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

2、构建client端所需配置文件及解释(注意:此时的配置文件一般命名为bootstrap.yml)

server:
port: 8002
spring:
application:
name: configclient
cloud:
config:
discovery:
serviceId: spring-cloud-config-server
enabled: true
name: configclient
profile: default,pre,two
label: master
profiles:
active: default,pre,two
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8000/eureka/

3、构建client端所需注解

@SpringBootApplication
@EnableEurekaClient

三、配置文件库

这个是我创建配置文件库的方法

直接操作github或gitlib的操作页面创建,然后更新到本地,以后就可以修改了

server端和client端代码参考:https://github.com/Pinshuducha/spring-cloud-config.git

配置文件库参考:https://github.com/Pinshuducha/config-file.git

springcloud之配置中心用法的更多相关文章

  1. 七、springcloud之配置中心Config(二)之高可用集群

    方案一:传统作法(不推荐) 服务端负载均衡 将所有的Config Server都指向同一个Git仓库,这样所有的配置内容就通过统一的共享文件系统来维护,而客户端在指定Config Server位置时, ...

  2. SpringCloud 分布式配置中心

    SpringCloud 分布式配置中心 服务端 创建工程并完善结构 国际惯例,把maven工程创建完善 pom.xml <?xml version="1.0" encodin ...

  3. SpringCloud分布式配置中心Config

    统一管理所有配置. 1.微服务下的分布式配置中心 简介:讲解什么是配置中心及使用前后的好处 什么是配置中心: 一句话:统一管理配置, 快速切换各个环境的配置 相关产品: 百度的disconf 地址:h ...

  4. 二十、springcloud(六)配置中心服务化和高可用

    1.问题描述 前一篇,spring-cloud-houge-provider(称之为客户端)直接从spring-cloud-houge-config(称之为服务端)读取配置,客户端和服务端的耦合性太高 ...

  5. 十九、springcloud(五)配置中心本地示例和refresh

    1.创建spring-cloud-houge-config子项目,测试需要的项目入下 2.添加依赖 <dependency> <groupId>org.springframew ...

  6. 六、springcloud之配置中心Config

    一.配置中心提供的核心功能 Spring Cloud Config为服务端和客户端提供了分布式系统的外部化配置支持.配置服务器为各应用的所有环境提供了一个中心化的外部配置.它实现了对服务端和客户端对S ...

  7. 微服务SpringCloud之配置中心和消息总线

    在微服务SpringCloud之Spring Cloud Config配置中心SVN博客中每个client刷新配置信息时需要post请求/actuator/refresh,但客户端越来越多时,,需要每 ...

  8. SpringCloud分布式配置中心

    一.什么是配置中心 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件.在Spring Cloud中,有分布式配置中心组件spring cloud c ...

  9. SpringCloud服务配置中心

    SpringCloud Config简介 Spring Cloud Config 是 Spring Cloud 团队创建的一个全新项目,用来为分布式系统中的基础设施和微服务应用提供集中化的外部配置支持 ...

随机推荐

  1. Linux tee命令使用详解分享

    tee命令主要被用来向standout(标准输出流,通常是命令执行窗口)输出的同时也将内容输出到文件,下面是tee的man 信息 read from standard input and write ...

  2. PHP curl采集

    if (function_exists('curl_init')) { //检查函数是否存在 $url = "http://***.com/"; $ch = curl_init() ...

  3. windows cmd command

    ////////////////// ===>windows + r //gpedit.msc 用户组策略 ///////////////// ===>cmd //ping www.bai ...

  4. python多线程,event,互斥锁,死锁,递归锁,信号量

    Python多线程/event 多线程-threading python的thread模块是⽐较底层的模块, python的threading模块是对thread做了⼀些包装的, 可以更加⽅便的被使⽤ ...

  5. HashMap(常用)方法个人理解

      Hashmap的存值: public static void main(String[] args) { ///*Integer*/map.put("1", 1);//向map ...

  6. Windos DNS Client 缓存

    要查看 DNS 缓存,请在命令提示符下键入 ipconfig /displaydns. 要从 DNS 缓存中删除该项,请在命令提示符下键入 ipconfig /flushdns. ipconfig.e ...

  7. 一篇关于Matcher find方法深刻理解的文章

    文章目录 知识点 find find(int var1) reset group(int var1) 源码 故事是这样的 探索 问题解决 方法一: 方法二: 方法三: 总结 知识点 find 首先fi ...

  8. shell脚本练习04

    ######################################################################### # File Name: -.sh # Author ...

  9. 在js中使用Razor

    @foreach (var tem in Model) { <text> time.push("@tem.CreateTime.ToString("G")&q ...

  10. Android开发 设备横屏与竖屏的详解

    需要了解横竖屏切换关键知识 1.在Android设备的横竖屏幕,每一次切换横竖屏其实是在重新创建Activity,Activity会重新走一遍生命周期.从onCreate 到 onDestroy 2. ...