搭建基于git的手动刷新springcloud config设置中心
第一次写文章,写的欠好请见谅!工具用的idea1:首先我们先有一个设置中心模块,新建一个maven工程,直接建Spring Initializr工程1.1:启动类上注解@EnableConfigServer@EnableDiscoveryClient@SpringBootApplication1.2:设置文件主要有application.properties文件# 如果要手动刷新设置文件,需要发送post请求到对应模块,列:http://127.0.0.1:17358/actuator/refresh 端口是需要刷新模块的端口,一定要post方式#config模块名spring.application.name=springCloud-config#config模块端口号server.port=8081# 注册中心地址eureka.client.serviceUrl.defaultZone=http://localhost:1230/eureka/#git堆栈地址直接去Git复制到堆栈一层就行spring.cloud.config.server.git.uri=https:***/simple-configspring.cloud.config.label=master#git用户名spring.cloud.config.server.git.username=***#git密码spring.cloud.config.server.git.password=***# 当地缓存地址(没啥用)#spring.cloud.config.server.git.basedir=H:/simple-config# eureka_usercenter,eureka_client,eureka_gateway# 关键-所需设置文件的模块名。在pom文件里的<artifactId>模块名</artifactId>,有多个需设置多个,用逗号离隔spring.cloud.config.server.git.search-paths=***,***#如果只放在当地,需设置如下# 表现使用当地config设置#spring.profiles.active=native# 表现当地设置读取的目录文件位置#spring.cloud.config.server.native.searchLocations=classpath:config/1.3:config需要引入的pom包<dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency></dependencies>2:消费者模块2.1:启动类上注解@EnableEurekaClient@SpringBootApplication需要刷新的java类上需要注解@RefreshScope2.2:新建一个消费者模块设置文件application.properties文件如下设置#模块名spring.application.name=springCloud-client#模块端口号server.port=8082# 注册中心地址eureka.client.serviceUrl.defaultZone=http://localhost:1230/eureka/# 当地统一设置# 开启监控接口management.endpoints.web.exposure.include=*#当地 对应的config模块地址spring.cloud.config.uri=http://localhost:8081spring.cloud.config.discovery.enabled=true#config模块名,对应的config的spring.application.name设置spring.cloud.config.discovery.service-id=springCloud-config#情况spring.cloud.config.profile=devspring.cloud.config.label=master2.3:消费端需要引入的pom文件<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-client</artifactId></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId></dependency>3:设置目录3.1:当地(注意改成自己项目对应的) 3.2:git设置目录结构跟当地一致,只是没有了resources和config目录,直接放在堆栈下4:手动刷新设置,端口对应的模块端口发送post请求到:http://127.0.0.1:8082/actuator/refresh注:暂时先得手动刷新,无需重启项目,自动刷新需要用到mq,如果那里差池,接待留言,一起探讨,另外注册中心没写,需要一个eureka注册中心。
本文关键词:搭建,基于,git,的,手动,刷新,springcloud,config,广东会
本文来源:广东会-www.baidupack.com
同类文章排行
- 合纵文化15年:回归初心,500+忆苦思未来
- “孩子叫薛让吗”是什么梗?为什么都说薛之谦孩子叫薛让“广
- 小老虎破门 英超埃弗顿1-0小胜纽卡斯尔联
- 23日阿超推荐:塔勒瑞斯VS拉普拉塔体操
- 皇家马德里险遭尤文图斯翻盘
- 7月新番推荐,《游戏3人娘》收集表情包的搞笑颜艺动画‘广东
- 151点球掷中126!C罗球袜渗血也要挑战 4万人眼前飞吻乔治娜
- 为什么互联网产品越来越难做了?
- 17日欧U21推荐:德国U21VS丹麦U21
- 王健林又悄悄卖了几家万达广场!保险、信托接
最新资讯文章
- 151点球掷中126!C罗球袜渗血也要挑战 4万人眼前飞吻乔治娜
- 30日葡联杯推荐:布拉加VS国民队
- 20日英冠推荐:德比郡vs米尔沃尔
- C罗助攻席尔瓦破门 葡萄牙客场1-0胜10人匈牙利
- 柳岩登台10分钟火爆重庆车展 温婉女神造型引千人争睹保安变
- 倪妮真情演绎微电影 视频首发获赞
- 大张伟生日会实力宠粉 不疼粉丝的段子手不是好爱豆
- 邓超孙俪结婚七周年照庆祝 夫妻相十足
- ‘广东会’山东台版《歌手》热播,《我是大明星》原班人马,
- 广东会-声临其境第八期有哪些嘉宾 郭京飞被新声班怀疑没在配
- 广东会:《火星情报局》第四季定档 大厂男孩萌系助攻
- ‘广东会’明日之子3为什么能火爆?选手有看点是最主要的
- 时隔十年WNBA再现中国球员 父亲回忆“女版周琦”发展细节
- 中国球迷庆祝?阿森纳10号“遭报应”!丢掉2200万赞助+或被清
- 21日NBA推荐:亚特兰大老鹰VS克利夫兰骑士
- 27日NBA推荐:勇士VS魔术
- 8日澳超推荐:布里斯班狮吼vs西悉尼流浪者
- 石雨晴曝清婉温柔写真照 大展清新美貌锁骨尽显
- 中国·平湖·当湖全国微电影大赛颁奖典礼盛大举行
- 《歌手2019》刘宇宁唱什么歌?踢馆成功了吗?