亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 Spring Cloud Bus 刷新配置更改

使用 Spring Cloud Bus 刷新配置更改

慕的地8271018 2022-05-25 16:49:25
我正在構建一個應用程序,使用 Spring Cloud 配置服務器作為保存屬性文件的集中位置。而且我有多個客戶端應用程序從配置服務器獲取配置數據。但是,我沒有手動刷新每個客戶端應用程序以在提交后提取屬性文件中的最新更改,而是使用 Spring 云總線和 Kafka 作為消息代理,以便所有更改都廣播到客戶端應用程序。下面是 pom 文件和屬性文件。配置服務器:pom       <dependency>            <groupId>org.springframework.cloud</groupId>            <artifactId>spring-cloud-config-server</artifactId>        </dependency>應用程序屬性:  server.port = 8980引導程序屬性:   spring.cloud.bus.enabled=true   spring.cloud.config.server.git.uri= "some path"配置客戶端:pom        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-actuator</artifactId>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-web</artifactId>        </dependency>        <dependency>            <groupId>org.springframework.cloud</groupId>            <artifactId>spring-cloud-starter-config</artifactId>        </dependency>        <dependency>            <groupId>org.springframework.cloud</groupId>            <artifactId>spring-cloud-starter-bus-kafka</artifactId>        </dependency>應用程序屬性:server.port=8982spring.cloud.bus.refresh.enabled: truespring.cloud.bus.env.enabled: trueendpoints.spring.cloud.bus.refresh.enabled: trueendpoints.spring.cloud.bus.env.enabled: truespring.cloud.stream.kafka.binder.autoAddPartitions=truespring.cloud.stream.kafka.binder.zkNodes=localhost:2181spring.cloud.stream.kafka.binder.brokers=localhost:9892引導程序屬性:    spring.application.name=department-service    spring.cloud.config.uri=http://localhost:8980    management.security.enabled=false但是在對本地 git 存儲庫文件進行更改并在我嘗試使用“ http://localhost:8982/actuator/bus-refresh ”端點提取最新更改后提交后,它給出了如下錯誤:{"timestamp": "2019-01-29T08:49:21.569+0000","status": 404,"error": "Not Found","message": "No message available","path": "/actuator/bus-refresh"}
查看完整描述

2 回答

?
撒科打諢

TA貢獻1934條經驗 獲得超2個贊

您需要在配置服務器 application.properties 中包含“management.endpoints.web.exposure.include=bus-refresh”。之后,向該 URL localhost:8012/actuator發送GET請求,以查看可用于刷新配置更改的LINKS 。您將在下面看到 JSON


{

"_links": {

    "self": {

        "href": "http://localhost:8012/actuator",

        "templated": false

    },

    "busrefresh-destinations": {

        "href": "http://localhost:8012/actuator/busrefresh/{*destinations}",

        "templated": true

    },

    "busrefresh": {

        "href": "http://localhost:8012/actuator/busrefresh",

        "templated": false

    }

}

然后你可以發送一個POST到這個URL localhost:8012/actuator/busrefresh


查看完整回答
反對 回復 2022-05-25
?
qq_遁去的一_1

TA貢獻1725條經驗 獲得超8個贊

您需要在配置服務器 application.properties 中包含“management.endpoints.web.exposure.include=bus-refresh”并點擊此 url

http://localhost:8980/actuator/bus-refresh


查看完整回答
反對 回復 2022-05-25
  • 2 回答
  • 0 關注
  • 148 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號