springcloud~配置中心实例搭建
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作为后缀,我们客户端就是某个应用程序,它以后从仓库获取配置信息。
程序配置例子
B(lind.yml)-->A(lind项目最终配置)
C(lind.svt.yml)-->A
D(lind.production.yml)-->A
lind.yml 默认的配置
lind.svt.yml 测试环境配置,将集成默认配置
lind.production.yml 生成环境配置,将集成默认配置
配置中心例子
A(用户服务)-->B(配置中心)
C(订单服务)-->B
D(商品服务)-->B
B-->E(Git仓库)
springcloud~配置中心实例搭建的更多相关文章
- SpringCloud配置中心实战
SpringCloud配置中心实战 1.统一配置中心(Config) 1.1 Spring项目配置加载顺序 1.2 配置规则详解 1.3 Git仓库配置 1.3.1 使用占位符 1.3.2 模式匹配 ...
- springcloud配置中心
SpringCloud Config简介 Spring Cloud Config 是 Spring Cloud 团队创建的一个全新项目,用来为分布式系统中的基础设施和微服务应用提供集中化的外部配置支持 ...
- SpringCloud配置中心config
1,配置中心可以用zookeeper来实现,也可以用apllo 来实现,springcloud 也自带了配置中心config Apollo 实现分布式配置中心 zookeeper:实现分布式配置中心, ...
- springcloud~配置中心的使用
配置中心作为springcloud里最底层的框架,所发挥的意思是举足轻重的,所以的组件的配置信息都可以通过springcloud config来管理,它会把配置信息分布式的存储到git上,所以信息安全 ...
- Consul作为SpringCloud配置中心
一.背景介绍 在分布式系统中动态配置中,可以避免重复重启服务,动态更改服务参数等.一句话非常重要. 另外一篇文章也是这样说的,哈哈. Consul 作为Spring 推荐的分布式调度系统其也具备配置中 ...
- springcloud配置中心客户端配置遇到的坑
1. 出错信息如下: 在启动配置中心的客户端时,报以下错误信息: Caused by: java.lang.IllegalArgumentException: Could not resolve pl ...
- SpringCloud配置中心集成Gitlab(十五)
一 开始配置config服务 config-server pom.xml <dependency> <groupId>org.springframework.cloud< ...
- 携程Apollo统一配置中心的搭建和使用
原文链接:https://blog.csdn.net/luhong327/article/details/81453001 一.Apollo配置中心介绍 1.What is Apollo 1.1 Ap ...
- Apollo配置中心环境搭建(Linux)
官方教程:https://github.com/ctripcorp/apollo/wiki/Apollo-Quick-Start-Docker%E9%83%A8%E7%BD%B2 方式二:使用apol ...
随机推荐
- Java基本类型和引用类型
8种基本类型 一.4种整型 byte 1字节 -128--127 short 2 字节 -32,768 -- 32,767 ...
- I/O-----字符输出流
package io.day04; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileR ...
- JUC中AQS简介
AQS,在java.util.concurrent.locks包中,AbstractQueuedSynchronizer这个类是并发包中的核心,了解其他类之前,需要先弄清楚AQS.在JUC的很多类中都 ...
- forwardport--源码笔记--注释
failed:", err.Error()) } }() } // log.Println("forwardPort ...
- OpenGL渲染管线(rendering pipeline)
OpenGL中的渲染管线包括:顶点着色器(vertex shader).细分着色器(里面包含两种:细分控制着色器和细分控制着色器)(tessellation shader).几何着色器.光栅化及片元着 ...
- BZOJ_3993_[SDOI2015]星际战争_二分+网络流
BZOJ_3993_[SDOI2015]星际战争_二分+网络流 Description 3333年,在银河系的某星球上,X军团和Y军团正在激烈地作战.在战斗的某一阶段,Y军团一共派遣了N个巨型机器人进 ...
- (4)STM32使用HAL库实现串口通讯——理论讲解
一.查询模式 1. 二.中断模式 1.中断接收. 1.1先看中断接收的流程(以 USART2 为例) 在启动文件中找到中断向量 USART2_IRQHandler 找到USART2_IRQHandle ...
- js 的 骚操作
单行的js 代码虽然简洁,但却不易维护,甚至难以理解, 但这却并不影响前端童鞋们编写简洁代码的热情, 一 , 生成随机ID // 生成长度为10的随机字母数字字符串 Math.random().t ...
- 软硬件协同编程 - C#玩转CPU高速缓存(附示例)
写在前面 好久没有写博客了,一直在不断地探索响应式DDD,又get到了很多新知识,解惑了很多老问题,最近读了Martin Fowler大师一篇非常精彩的博客The LMAX Architecture, ...
- mongodb副本集实现
目录 1. 简单介绍 primary: secondary: arbiter: 2.系统环境设置: 3.安装mongodb 安装mongodb 增加配置文件: 添加启动脚本 3. 副本集实现: 1. ...