server端

build.gradle相关

dependencies {
compile('org.springframework.cloud:spring-cloud-config-server',
'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server'
)
testCompile('org.springframework.boot:spring-boot-starter-test')
} dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

bootstrap.yml配置

server:
port: 8200
spring:
application:
name: lind-config-server
cloud:
config:
server:
git:
uri: https://github.com/bfyxzls/lindconfig.repo.git/
search-paths: config-repo
username: bfyxzls@sina.com
password: xxxx

启动项相关

@EnableDiscoveryClient
@EnableConfigServer
@SpringBootApplication
class Application {
public static void main(String[] args) {
// demo http://localhost://8200/email-svt.yml
SpringApplication.run(Application.class, args);
}
}

客户端

build.gradle相关

dependencies {
compile('org.springframework.boot:spring-boot-starter-web',
'org.springframework.cloud:spring-cloud-starter-config',
'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server')
testCompile('org.springframework.boot:spring-boot-starter-test')
} dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

bootstrap.yml配置

spring:
application:
name: lind
cloud:
config:
uri: http://localhost:8200
profile: svt
label: master #当 ConfigServer 的后端存储的是 Git 的时候,默认就是 master eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/

启动项相关

@EnableEurekaClient
@SpringBootApplication
public class Application { public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
} @RestController
public class HomeController { @Autowired
private Environment profile; @RequestMapping("/")
public String index(@RequestParam String key) { return key + "=" + profile.getProperty(key);
}
}

配置文件仓库

这是一个GIT仓库,主要存储我们的配置文件的,以application.name作为文件名,profile作为后缀,我们客户端就是某个应用程序,它以后从仓库获取配置信息。

程序配置例子

graph TD
B(lind.yml)-->A(lind项目最终配置)
C(lind.svt.yml)-->A
D(lind.production.yml)-->A

lind.yml 默认的配置

lind.svt.yml 测试环境配置,将集成默认配置

lind.production.yml 生成环境配置,将集成默认配置

配置中心例子

graph TD
A(用户服务)-->B(配置中心)
C(订单服务)-->B
D(商品服务)-->B
B-->E(Git仓库)

springcloud~配置中心实例搭建的更多相关文章

  1. SpringCloud配置中心实战

    SpringCloud配置中心实战 1.统一配置中心(Config) 1.1 Spring项目配置加载顺序 1.2 配置规则详解 1.3 Git仓库配置 1.3.1 使用占位符 1.3.2 模式匹配 ...

  2. springcloud配置中心

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

  3. SpringCloud配置中心config

    1,配置中心可以用zookeeper来实现,也可以用apllo 来实现,springcloud 也自带了配置中心config Apollo 实现分布式配置中心 zookeeper:实现分布式配置中心, ...

  4. springcloud~配置中心的使用

    配置中心作为springcloud里最底层的框架,所发挥的意思是举足轻重的,所以的组件的配置信息都可以通过springcloud config来管理,它会把配置信息分布式的存储到git上,所以信息安全 ...

  5. Consul作为SpringCloud配置中心

    一.背景介绍 在分布式系统中动态配置中,可以避免重复重启服务,动态更改服务参数等.一句话非常重要. 另外一篇文章也是这样说的,哈哈. Consul 作为Spring 推荐的分布式调度系统其也具备配置中 ...

  6. springcloud配置中心客户端配置遇到的坑

    1. 出错信息如下: 在启动配置中心的客户端时,报以下错误信息: Caused by: java.lang.IllegalArgumentException: Could not resolve pl ...

  7. SpringCloud配置中心集成Gitlab(十五)

    一 开始配置config服务 config-server pom.xml <dependency> <groupId>org.springframework.cloud< ...

  8. 携程Apollo统一配置中心的搭建和使用

    原文链接:https://blog.csdn.net/luhong327/article/details/81453001 一.Apollo配置中心介绍 1.What is Apollo 1.1 Ap ...

  9. Apollo配置中心环境搭建(Linux)

    官方教程:https://github.com/ctripcorp/apollo/wiki/Apollo-Quick-Start-Docker%E9%83%A8%E7%BD%B2 方式二:使用apol ...

随机推荐

  1. BZOJ_4476_[Jsoi2015]送礼物_01分数规划+单调队列

    BZOJ_4476_[Jsoi2015]送礼物_01分数规划+单调队列 Description JYY和CX的结婚纪念日即将到来,JYY来到萌萌开的礼品店选购纪念礼物. 萌萌的礼品店很神奇,所有出售的 ...

  2. Ubuntu18.04美化主题(mac主题)

    前端时间Ubuntu18.04LTS发布,碰巧之前用的Ubuntu16.04出了一点问题,懒得解决,索性就换了Ubuntu18.04. 成果: 参考博客:https://www.cnblogs.com ...

  3. MYSQL—— Insert的几种用法!

    向表中插入数据 标题头示例图如下: 用insert插入值得方式: 1.使用如下语句进行插入值操作,要求:插入值必须与表头给出列数值一致,否则报:[Err] 1136 - Column count do ...

  4. 【原】js数组对象去重最简单的方法

    简单的数组去重是比较简单的,方法也特别多,如给下面的数组去重: let arr = [1,2,2,4,9,6,7,5,2,3,5,6,5] 最常用的可以用for循环套for循环,再用splice删除重 ...

  5. 经典卷积神经网络结构——LeNet-5、AlexNet、VGG-16

    经典卷积神经网络的结构一般满足如下表达式: 输出层 -> (卷积层+ -> 池化层?)+  -> 全连接层+ 上述公式中,“+”表示一个或者多个,“?”表示一个或者零个,如“卷积层+ ...

  6. 如何在ASP.NET Core中使用Azure Service Bus Queue

    原文:USING AZURE SERVICE BUS QUEUES WITH ASP.NET CORE SERVICES 作者:damienbod 译文:如何在ASP.NET Core中使用Azure ...

  7. Docker安装+HelloWorld+运行Tomcat

    前言 只有光头才能变强. 文本已收录至我的GitHub仓库,欢迎Star:https://github.com/ZhongFuCheng3y/3y 上一篇已经讲解了为什么需要Docker?,相信大家已 ...

  8. windows代码,路径分割

    BOOL SplitPathName( PWSTR MyXbpathBuffer, wstring& wdrive, wstring& wdir, wstring& wfnam ...

  9. <转载>Android性能优化之HashMap,ArrayMap和SparseArray

    本篇博客来自于转载,打开原文地址已经失效,在此就不贴出原文地址了,如原作者看到请私信我可用地址,保护原创,人人有责.   Android开发者都知道Lint在我们使用HashMap的时候会给出警告—— ...

  10. 在ArcMap中发布FeatureLayer(要素图层)

    FeatureLayer(要素图层)是ArcGIS Server发布的一种很重要的地图服务,发布后使用提供的url地址就可以在代码中调用并在地图上显示.编辑这个FeatureLayer.在HTML页面 ...