网站首页 > 开源技术 正文
01
前言
使用分布式微服务开发和部署项目,其中的一个优势就是:使用分布式配置协调服务,达到统一配置存储和使用。
比如百度的disconf,阿里的diamand。都是不错的分布式统一配置框架,SpringCloud-config Server则是SpringCloud系列下的分布式统一配置组件服务。
02
简单介绍
SpringCloud-config Server的maven依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
解决方案架构示意图
03
Config-Server配置中心示意图
Spring cloud config是将配置保存在远程服务gitlab/git/svn进行托管,小编这里用的是gitlab,其用法和结构原理跟git/github用起来差不多。
项目中的gitlab配置信息如下:
spring:
application:
name: config-center
cloud:
config:
enabled: true
server:
git:
uri: http://172.2*.4.*0/e**s/application-config.git
username: **s # git账户用户
password: **s1234 #git账户密码
search-paths: /config-s*o,/config-t*s,/config-c*,/config-h*s...#
git项目中子目录
git.uri就是配置的gitlab的地址,以及usrname和password信息。search-paths是各子系统的配置对应文件目录。
configServer项目启动的时候,Spring就会去读取gitlab连接和配置信息,并创建连接以读取各个子项目的配置信息。
当然,configServer也要自己在ereka中进行服务注册,以供其他子模块服务可以访问和消费信息。
eureka:
client:
service-url:
defaultZone: http://17*.2*.4.*0:8000/eureka/
项目中的注解
@Configuration
@EnableAutoConfiguration
@EnableConfigServer
@SpringBootApplication
@EnableDiscoveryClient
public class ConfigCenterApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigCenterApplication.class, args);
}
}
其中:@EnableConfigServer就是标注本项目实例,是ConfigServer的实例。结合上面的@Configuration和@EnableAutoConfiguration自动加载配置注解,Spring就会去自动加载配置信息。例如上面所说的连接gitlab等。
启动之后,configServer经由ereka服务注册和发现,供其他子模块系统消费。所以,configServer是必须首先开发和部署的模块,并且应与其他业务模块分离单独出来。部署好之后,才能开发和部署其他子模块项目。
猜你喜欢
- 2024-10-28 成为java微服务架构师的技术学习路线图
- 2024-10-28 Re:从 0 开始的微服务架构:(二)如何快速体验微服务架构?
- 2024-10-28 WormHole服务网关管理平台(网关服务器)
- 2024-10-28 亿级流量网站架构核心技术「笔记」(一)
- 2024-10-28 架构师必懂的——分布式配置中心(Apollo)
- 2024-10-28 那些Java架构师必知必会的技术(那些java架构师必知必会的技术知识)
- 2024-10-28 Dubbo微服务架构下的Kubernetes云平台建设实践
- 2024-10-28 架构学习之路——高可用高并发系统设计原则
- 2024-10-28 配置中心的原理是什么?(配置中心能放哪些内容)
- 2024-10-28 最全的微服务知识科普(服务 微服务)
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- jdk (81)
- putty (66)
- rufus (78)
- 内网穿透 (89)
- okhttp (70)
- powertoys (74)
- windowsterminal (81)
- netcat (65)
- ghostscript (65)
- veracrypt (65)
- asp.netcore (70)
- wrk (67)
- aspose.words (80)
- itk (80)
- ajaxfileupload.js (66)
- sqlhelper (67)
- express.js (67)
- phpmailer (67)
- xjar (70)
- redisclient (78)
- wakeonlan (66)
- tinygo (85)
- startbbs (72)
- webftp (82)
- vsvim (79)
本文暂时没有评论,来添加一个吧(●'◡'●)