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 ...
随机推荐
- tensorflow 使用 2 Felch ,Feed
Felch ::在会话里可以执行多个 op , import tensorflow as tf input1 = tf.constant(3.0) input2 = tf.constant(2.0) ...
- windows server 远程桌面连接问题。
远程桌面连接相当于 linux 服务器root权限连接 mstsc /admin /v:目标IP mstsc /admin /
- Angular 2项目的环境配置和项目搭建
AngularJS2 发布于2016年9月份,它是基于ES6来开发的. AngularJS2 是一款开源JavaScript库,由Google维护,用来协助单一页面应用程序运行.AngularJS2 ...
- vue 时间戳 转 日期
<text style="padding-right: 10px; color: #333; font-size: 28px" slot="value"& ...
- 为什么导入本地jquery.js老是无效?(已解决)
我从jquery官网里复制过来jquery.js内容,然后粘贴到本地,但是引用的时候总是无效. 在翻看脚本所在目录,无意间发现脚本文件是个jquery.js.js, 原来是我的文件的扩展名的问题 ...
- css实现超出两行隐藏
overflow:hidden; text-overflow:ellipsis; display:-webkit-box; -webkit-box-orient:vertical; -webkit-l ...
- C++之几个最常
1.同类对象间的数据共享——静态成员 静态数据成员声明静态数据成员要采用关键字static:类静态数据成员的定义和初始化定义:static 数据类型 成员名:初始化:数据类型 类名::静态数据成员名= ...
- Web测试入门:Selenium+Chrome+Python+Mac OS
一.环境配置 Chromedriver 下载及环境配置 url:使用WebDriver在Chrome浏览器上进行测试时,需要从http://chromedriver.storage.googleapi ...
- 面试作业之浅析京东促销活动核心模型 - DDD
前言 京东作为中国最大的自营式B2C电商平台,提供一站式综合性购物,服务亿万家庭,涵盖3C.家电.消费品.服饰.家居家装.生鲜和新通路(B2B),满足了消费者的多元化需求.每天都会发布相关的促销活动, ...
- spring的定时器
一:基于xml配置的方式 1:编写普通的pojo 类 package com.aflyun.web.task; import org.springframework.stereotype.Compon ...