SpringCloud Config服务端
1、导入依赖
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-config-server</artifactId>
- </dependency>
2、使用@EnableConfigServer开启配置中心服务端支持
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- import org.springframework.boot.builder.SpringApplicationBuilder;
- import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
- import org.springframework.cloud.config.server.EnableConfigServer;
- @SpringBootApplication
- @EnableDiscoveryClient
- @EnableConfigServer //开启配置中心服务端支持
- public class ConfigServerApplication {
- public static void main(String[] args) {
- new SpringApplicationBuilder(ConfigServerApplication.class).web(true).run(args);
- }
- }
3、创建git仓库项目并上传配置文件
4、在application.yml文件中配置git远程仓库信息
- security:
- basic:
- enabled: false
- spring:
- application:
- name: mima-cloud-config-server
- cloud:
- consul:
- discovery:
- instanceId: ${spring.application.name}:${server.port}
- host: localhost
- port: 8500
- config:
- enabled: true #false\u7981\u7528Consul\u914d\u7f6e\uff0c\u9ed8\u8ba4true
- format: YAML # \u8868\u793aconsul\u4e0a\u9762\u6587\u4ef6\u7684\u683c\u5f0f \u6709\u56db\u79cd YAML PROPERTIES KEY-VALUE FILES
- #data-key: configuration #\u8868\u793aconsul\u4e0a\u9762\u7684KEY\u503c(\u6216\u8005\u8bf4\u6587\u4ef6\u7684\u540d\u5b57) \u9ed8\u8ba4\u662fdata
- data-key: data #\u8868\u793aconsul\u4e0a\u9762\u7684KEY\u503c(\u6216\u8005\u8bf4\u6587\u4ef6\u7684\u540d\u5b57) \u9ed8\u8ba4\u662fdata
- #prefix\u8bbe\u7f6e\u914d\u7f6e\u503c\u7684\u57fa\u672c\u6587\u4ef6\u5939
- #defaultContext\u8bbe\u7f6e\u6240\u6709\u5e94\u7528\u7a0b\u5e8f\u4f7f\u7528\u7684\u6587\u4ef6\u5939\u540d\u79f0
- #profileSeparator\u8bbe\u7f6e\u7528\u4e8e\u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\u5728\u5c5e\u6027\u6e90\u4e2d\u5206\u9694\u914d\u7f6e\u6587\u4ef6\u540d\u79f0\u7684\u5206\u9694\u7b26\u7684\u503c
- config:
- server:
- git:
- #git远程地址
- uri: https://gitee.com/lynch168/config-file
- #搜索目录
- search-paths: /**
- #git默认分支
- default-label: master
- #如果为私有仓库,需要设置用户名、密码
- #username:
- #password:
- #是否开启配置中心
- enabled: true
- #默认的分支
- label: master
- server:
- port: 6063
启动config-server服务。
5、浏览器上访问配置文件
http://localhost:6063/application-prod.properties
http://localhost:6063/application-uat.yml
SpringCloud Config服务端的更多相关文章
- Spring Cloud Config 服务端与 客户端之间的关系
1.服务端有两个可配置项 # 是否在服务器端进行解密操作,默认开启. # 如果改为不在服务器端开启(false) # 那么一定要将encrypt.key 删除. # 否则会出现客户端无法解密. # 为 ...
- Spring Cloud (6)A config 服务端配置 与github通信
1. 在git上创建一个库,并复制库地址 2.用git clone项目到本地,并创建application.yml application.yml 内容 --下一步 3.将application.ym ...
- SpringCloud与微服务Ⅹ --- SpringCloud Config分布式配置中心
一.SpringCloud Config是什么 分布式系统面临的问题 --- 配置问题 微服务意味着要将单体应用中的业务拆分成一个个子服务,每个服务的粒度相对较小,因此系统中会出现大量的服务.由于每个 ...
- SpringCloud Config客户端
SpringCloud Config服务端 1.导入依赖 <dependency> <groupId>org.springframework.cloud</groupI ...
- SpringCloud 进阶之分布式配置中心(SpringCloud Config)
1. SpringCloud Config SpringCLoud Config 为微服务架构中的微服务提供集中化的外部配置支持,配置服务器为各个不同微服务应用 的所有环境提供了一个中心化的外部配置; ...
- SpringCloud学习笔记(二、SpringCloud Config)
目录: 配置中心简介 SpringCloud Config服务端 SpringCloud Config客户端 动态配置属性bean 一些补充(源码分析):Spring事件监听.健康检查health() ...
- SpringCloud学习笔记(九):SpringCloud Config 分布式配置中心
概述 分布式系统面临的-配置问题 微服务意味着要将单体应用中的业务拆分成一个个子服务,每个服务的粒度相对较小,因此系统中会出现大量的服务.由于每个服务都需要必要的配置信息才能运行,所以一套集中式的.动 ...
- SpringCloud-微服务配置统一管理SpringCloud Config(七)
前言:对于应用,配制文件通常是放在项目中管理的,它可能有spring.mybatis.log等等各种各样的配置文件和属性文件,另外你还可能有开发环境.测试环境.生产环境等,这样的话就得一式三份,若是传 ...
- SpringCloud微服务学习笔记
SpringCloud微服务学习笔记 项目地址: https://github.com/taoweidong/Micro-service-learning 单体架构(Monolithic架构) Mon ...
随机推荐
- 微信跳转技术,浏览器唤起微信,weixin://dl/business/?ticket=
weixin://dl/business/?ticket= 到底怎么生成的?调用以下接口 weixin://dl/scan 扫一扫weixin://dl/feedback 反馈weixin://dl ...
- c#提交事务的两种方法
1. using (TransactionScope ts = new TransactionScope()) { 除非显示调用ts.Complete()方法.否则,系统不会自动提交这个事务.如果在代 ...
- linq给list集合数据分页
var lastlist= newlist.Skip(pageindex * pagesize).Take(pagesize);
- centos7.5安装python3.7
系统状态 CentOS Linux release 7.5.1804 (Core) mini版安装系统 Python-3.7.0.tgz 官方下载源码包 安装系统依赖包 # 编译必备 yum inst ...
- 编译部署 Mysql 5.7
1.环境准备 RHEL7.4(最小化安装) 64bit 2G 内存 (1G 内存编译将近一个小时) 磁盘空间 15G 以上. 配置为本地yum 源 从MySQL5.7版本开始,安装MySQL需要 ...
- Java Fileupload
fileupload FileUpload 是 Apache commons下面的一个子项目,用来实现Java环境下面的文件上传功能,与常见的SmartUpload齐名. 组件 1.FileUpLoa ...
- 微信小程序如何发送短信验证码,无需搭建服务器
自从微信小程序提供云开发支持,开发者无需搭建后台服务器,使用微信提供的核心API就可以实现应用功能,此时就需要小程序能够自己发送短信,比如短信验证码,榛子云短信(http://smsow.zhenzi ...
- json 的使用 Java对象转json
1. jsonlib:个人感觉最麻烦的一个需要导入的包也多,代码也相对多一些. 2.Gson:google的 3.FastJson:阿里巴巴的,个人觉得这个比较好,而且据说这个也是性能最好一个. 下面 ...
- 字符串----HDU-1358
题目大意:求字符串的前缀是否为周期串,若是,打印出循环节的长度以及循环次数. 这道题考察的是KMP算法中next数组的应用,必须理解透next[]数组代表的含义才t能通过它解决这道题.思路是先构造出 ...
- Spring Cloud 微服务架构的五脏六腑,统统晒一晒!
Spring Cloud 是一个基于 Spring Boot 实现的微服务框架,它包含了实现微服务架构所需的各种组件. 注:Spring Boot 简单理解就是简化 Spring 项目的搭建.配置.组 ...