Spring cloud config

Spring cloud config,配置管理工具包,让你可以把配置放到远程服务器,集中化管理集群配置,目前支持本地存储、Git以及Subversion。

配合spring cloud bus 传播配置文件的变化可实现热部署

config分为服务端和客户端,服务端负责与仓库建立连接,客户端通过服务端拿到配置数据。

config 服务端:

1、pom文件引入:

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>

2、配置文件:

spring:
cloud:
config:
server:
git:
uri: https://github.com/***/***
search-paths:
- data
uri:为仓库地址,如github上仓库
search-paths:搜索路径

3、主类:

1 @SpringBootApplication
2 @EnableConfigServer
3 @EnableDiscoveryClient    
4 public class ConfigApplication {
5     public static void main(String[] args) {
6         SpringApplication.run(ConfigApplication.class, args);
7     }
8 }

config客户端:

1、pom文件引入

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>

2、配置文件

spring:
cloud:
config:
uri: http://ConfigServer:8001
name: servicedemo
uri: config服务器名:端口号

3、主类

    无

posted @ 2017-04-17 16:33  yanyouqiang  阅读(401)  评论(0编辑  收藏  举报