# bs-server-config **Repository Path**: SpringCloudTestGroup/bs-server-config ## Basic Information - **Project Name**: bs-server-config - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2018-11-26 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # bs-server-config #### 项目介绍 ``` Spring Cloud Config就是云端存储配置信息的,它具有中心化,版本控制,支持动态更新,平台独立,语言独立等特性。其特点是:   1.提供服务端和客户端支持(spring cloud config server和spring cloud config client)   2.集中式管理分布式环境下的应用配置   3.基于Spring环境,无缝与Spring应用集成   4.可用于任何语言开发的程序   5.默认实现基于git仓库,可以进行版本管理   6.可替换自定义实现 ``` ``` spring cloud config包括两部分:   1.spring cloud config server 作为配置中心的服务端:     1.拉取配置时更新git仓库副本,保证是最新结果     2.支持数据结构丰富,yml, json, properties 等     3.配合 eureke 可实现服务发现,配合 cloud bus 可实现配置推送更新     4.配置存储基于 git 仓库,可进行版本管理     5.简单可靠,有丰富的配套方案   2.Spring Cloud Config Client 客户端:     1.Spring Boot项目不需要改动任何代码,加入一个启动配置文件指明使用ConfigServer上哪个配置文件即可 ``` #### 软件架构 ![配制中心](https://images.gitee.com/uploads/images/2018/1213/152519_5c0fb938_1680448.png "配制中心.png") #### 安装教程 1. POM引入父工程 ``` com.example bs-cloud-parent 0.0.1-SNAPSHOT ``` 2. POM配制中心服务端 ``` org.springframework.cloud spring-cloud-config-server org.springframework.cloud spring-cloud-starter-bus-amqp ``` 3. POM注册中心客户端 ``` org.springframework.cloud spring-cloud-starter-netflix-eureka-client ``` 4. bootstrap.yml ``` spring: application.name : bs-server-config`本应用的服务名称` profiles.active: dev`默认环境配制` cloud: config:`注册配制中心的git仓库` server: git: ignore-local-ssh-settings: true skip-ssl-validation: true uri: https://gitee.com/SpringCloudTestGroup/bs-config-files.git`注册配制中心git地址` username: user password: pwd bootstrap: true eureka: instance: prefer-ip-address: true client:`注册中心客户端引入注册中心地址` service-url: defaultZone: http://你的注册中心IP1:PORT/eureka/,http://你的注册中心IP2:PORT/eureka/ 如果有busmq还要加是 mq信息 ``` #### 使用说明 1. 程序入口 ``` package com.example.config; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.config.server.EnableConfigServer; @SpringBootApplication @EnableConfigServer`标记配制中心服务器端` @EnableDiscoveryClient`标记注册中心客户端` public class ConfigServerApplication { public static void main(String[] args) { long starTime = System.currentTimeMillis(); SpringApplication.run(ConfigServerApplication.class, args); long endTime = System.currentTimeMillis(); long time = endTime - starTime; System.out.println("\nStart Time: " + (time / 1000) + " s"); System.out.println("..............................................................."); System.out.println("..................Service starts successfully.................."); System.out.println("..............................................................."); } } ``` 2. 客户端部分 [参考bs-service-a工程](https://gitee.com/SpringCloudTestGroup/bs-service-a) 3. xxxx #### 参考贡献 1. 狂小白 SpringCloud实战7-Config分布式配置管理 https://www.cnblogs.com/huangjuncong/p/9069749.html SpringCloud Config(配置中心)实现配置自动刷新总结 https://blog.csdn.net/wtdm_160604/article/details/83720391 2. 配制中心仓库-bs-config-files [bs-config-files](https://gitee.com/SpringCloudTestGroup/bs-config-files)