日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SrpingCloud 之SrpingCloud config分布式配置中心实时刷新

發布時間:2025/4/9 编程问答 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SrpingCloud 之SrpingCloud config分布式配置中心实时刷新 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

默認情況下是不能及時獲取變更的配置文件信息

Spring Cloud分布式配置中心可以采用手動或者自動刷新

?1、手動需要人工調用接口? ?監控中心

?2、消息總線實時通知? springbus

?

動態刷新數據

在SpringCloud中有手動刷新配置文件和實時刷新配置文件兩種方式。

手動方式采用actuator端點刷新數據

實時刷新采用SpringCloud Bus消息總線

?

?

??

actuator端點刷新數據

在config clientr引入?

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId> </dependency>

  

yml中開啟監控斷點

management:endpoints:web:exposure:include: "*"

 同時在controller加 @RefreshScope 

package com.toov5.controller;import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;@RestController @RefreshScope public class TestController {@Value("${motto}") //配置的keyprivate String motto;@RequestMapping("/getMotto")public String getMotto() {return motto;} }

?

開啟: 修改git上的配置文件信息

必須要用post請求!

http://127.0.0.1:8882/actuator/refresh

?

成功!

?每個客戶端都有監聽,效果不是很好這樣的方式。手動刷新比較好一些。改完了自己手動刷新下 post 調用一下

高級的spring cloud bus: https://www.cnblogs.com/toov5/p/10293755.html?

轉載于:https://www.cnblogs.com/toov5/p/9966822.html

總結

以上是生活随笔為你收集整理的SrpingCloud 之SrpingCloud config分布式配置中心实时刷新的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。