springcloud之配置中心用法
一、配置文件服务器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之配置中心用法的更多相关文章
- 七、springcloud之配置中心Config(二)之高可用集群
方案一:传统作法(不推荐) 服务端负载均衡 将所有的Config Server都指向同一个Git仓库,这样所有的配置内容就通过统一的共享文件系统来维护,而客户端在指定Config Server位置时, ...
- SpringCloud 分布式配置中心
SpringCloud 分布式配置中心 服务端 创建工程并完善结构 国际惯例,把maven工程创建完善 pom.xml <?xml version="1.0" encodin ...
- SpringCloud分布式配置中心Config
统一管理所有配置. 1.微服务下的分布式配置中心 简介:讲解什么是配置中心及使用前后的好处 什么是配置中心: 一句话:统一管理配置, 快速切换各个环境的配置 相关产品: 百度的disconf 地址:h ...
- 二十、springcloud(六)配置中心服务化和高可用
1.问题描述 前一篇,spring-cloud-houge-provider(称之为客户端)直接从spring-cloud-houge-config(称之为服务端)读取配置,客户端和服务端的耦合性太高 ...
- 十九、springcloud(五)配置中心本地示例和refresh
1.创建spring-cloud-houge-config子项目,测试需要的项目入下 2.添加依赖 <dependency> <groupId>org.springframew ...
- 六、springcloud之配置中心Config
一.配置中心提供的核心功能 Spring Cloud Config为服务端和客户端提供了分布式系统的外部化配置支持.配置服务器为各应用的所有环境提供了一个中心化的外部配置.它实现了对服务端和客户端对S ...
- 微服务SpringCloud之配置中心和消息总线
在微服务SpringCloud之Spring Cloud Config配置中心SVN博客中每个client刷新配置信息时需要post请求/actuator/refresh,但客户端越来越多时,,需要每 ...
- SpringCloud分布式配置中心
一.什么是配置中心 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件.在Spring Cloud中,有分布式配置中心组件spring cloud c ...
- SpringCloud服务配置中心
SpringCloud Config简介 Spring Cloud Config 是 Spring Cloud 团队创建的一个全新项目,用来为分布式系统中的基础设施和微服务应用提供集中化的外部配置支持 ...
随机推荐
- AFO成功
在dcoi一年多,还是发生了不少事情. 过程中也有些小遗憾,有做错的事情,有搞砸的事情,有没办法挽回的事情,这种没法读档的辣鸡游戏也是无可奈何的.对所有被我搞砸的事情说声对不起啦,至少在下一次的时候, ...
- iOS开发NSLayoutConstraint代码自动布局
1.NSLayoutConstraint简介 适配界面大多用Masonry工具,也是基于NSLayoutConstraint写的!通过使用两个类方法实现自动布局: + (NSArray<__ki ...
- 如何在 JavaScript 中使用 C 程序
JavaScript 是个灵活的脚本语言,能方便的处理业务逻辑.当需要传输通信时,我们大多选择 JSON 或 XML 格式. 但在数据长度非常苛刻的情况下,文本协议的效率就非常低了,这时不得不使用二进 ...
- substring常用的两种方法
1.public String substring(int beginIndex, int endIndex) 第一个参数int为开始的索引,对应String数字中的开始位置, 第二个参数是截止的索引 ...
- js基础应用-打字机,震动窗口
js基础应用一,窗口震动 html+js代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8 ...
- Spark如何读写hive
原文引自:http://blog.csdn.net/zongzhiyuan/article/details/78076842 hive数据表建立可以在hive上建立,或者使用hiveContext.s ...
- 图片上传的ImageIO工具类
ImageIO类说明 最近的项目中遇到ImageIO,因此记录下这个类的用法 一.ImageIO: 这个类中的方法都是静态方法,可以用来进行简单的图片IO操作 1.读入的三种方法 public sta ...
- MySQL数据库CRUD命令用法
数据库CRUD操作即添加(Create).读取(Read).更新(Update)和删除(Delete). 1. 添加操作也称插入操作,使用Insert语句,Insert语句可以用于几种情况: 插入完整 ...
- 廖雪峰Java15JDBC编程-1关系数据库基础-1关系数据库简介
1.数据库 1.1 定义 数据库是按照数据结构来组合.存储和管理数据的软件. 1.2 数据库模型 数据库有层次模型.网状模型.关系模型三种模型. 2 关系数据库 关系数据库是建立在关系模型上的数据库, ...
- 网络编程(client发信息给server)
client发信息给server