国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Spring Cloud之Config分布式配置應?

這篇具有很好參考價值的文章主要介紹了Spring Cloud之Config分布式配置應?。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

. 右鍵??程【 yx-parent 】選擇【 New - Module 】選項,然后選擇創(chuàng)建【 Maven 】類型項?(不勾選模 板),將項?名稱設置為【yx-cloud-config 】。
Spring Cloud之Config分布式配置應?,spring cloud,分布式,spring

?yx-cloud-config?程的pom.xml?件中引?以下依賴坐標(需要將??注冊到Eureka)。

 <dependencies>
        <!-- Eureka Client客戶端依賴引入 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency>
        <!-- Config配置中心服務端 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>
    </dependencies>
com.yx.config 包下創(chuàng)建 ConfigApplication 啟動類,使?注解 @EnableConfigServer 開啟配置中?服務器功 能。
package com.yx.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;
@EnableConfigServer // 開啟配置服務器功能
@EnableDiscoveryClient
@SpringBootApplication
public class ConfigApplication {
 public static void main(String[] args) {
 SpringApplication.run(ConfigApplication.class, args);
 }
}
yx-cloud-config ?程的 resources ?錄下創(chuàng)建 application.yml 配置?件并添加以下配置。
server:
  port: 9400

# 注冊到Eureka服務中心
eureka:
  client:
    service-url:
      defaultZone: http://YXCloudEurekaServerC:9200/eureka,http://YXCloudEurekaServerD:9201/eureka
  instance:
    prefer-ip-address: true
    instance-id: ${spring.cloud.client.ip-address}:${spring.application.name}:${server.port}:@project.version@
spring:
  application:
    name: yx-service-config
  cloud:
    config:
      server:
        git: #用于配置git倉庫信息:uri,
          uri: https://gitee.com/zhengchunbo/yx-config.git
          username: **
          password: *****
          search-paths: #表示倉庫的名稱
            - yx-config
      label: master # 讀取分?

Spring Cloud之Config分布式配置應?,spring cloud,分布式,spring

?5.啟動yx-cloud-config?程,訪問http://127.0.0.1:9400/master/application-dev.yml地址進?測試

3. 構(gòu)建 Client 客戶端
在page消費者微服務 pom.xml ?件中添加 config-client 依賴坐標
<dependency>
<groupId> org.springframework.cloud </groupId>
<artifactId> spring-cloud-config-client </artifactId>
</dependency>

在page消費者微服務的application.yml?件名稱修改為bootstrap.yml。并在為bootstrap.yml?件中對config 進?配置。

spring:
  # ?式1:暴露指定refresh端?
  management:
    endpoints:
     web:
      exposure:
       include: refresh
  application:
    name: yx-service-page
  cloud:
    config:
    # config客戶端配置和ConfigServer通信,并告知ConfigServer希望獲取的配置信息在哪個?件中
     name: application  #表示獲取ConfigServer 中的配置文件名稱(application-dev)
     profile: dev # 后綴名稱
     label: master # 分?名稱
     uri: http://localhost:9400 # ConfigServer配置中?地址

Spring Cloud之Config分布式配置應?,spring cloud,分布式,spring

package com.yx.page.controller;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RequestMapping("config")
@RestController
public class ConfigController {
 @Value("${mysql.user}")
 private String mysqlUser;
 @Value("${person.name}")
 private String personName;
 @RequestMapping("remote")
 public String getRemoteConfig() {
 return "mysqlUser=" + mysqlUser + ", personName=" + personName;
 }
}
Config 配置?動刷新
1.在消費者模塊添加 springboot-starter-actuator 依賴(已在??程中添加)
2. Client 客戶端(消費者 模塊)的 bootstrap.yml(前面步驟已經(jīng)把application.yml改為了booststrap.yml) ?件中添加配置(暴露通信端點,已添加)
Spring Cloud之Config分布式配置應?,spring cloud,分布式,spring

Spring Cloud之Config分布式配置應?,spring cloud,分布式,spring

?在消費者的collection類上使?到配置信息的類上添加@RefreshScope注解

Spring Cloud之Config分布式配置應?,spring cloud,分布式,spring
4. ?動向 Client 客戶端發(fā)起 POST 請求 http://localhost:9100/actuator/refresh ,即可完成刷新配置信息
Spring Cloud之Config分布式配置應?,spring cloud,分布式,spring

?Spring Cloud Config+Spring Cloud Bus實現(xiàn)?動刷新

1. Config Server 服務端( yx-cloud-config 模塊)和客戶端( yx-service-page 模塊)添加消息總線?持,引? bus-amp依賴
<dependency>
 <groupId>org.springframework.cloud</groupId>
 <artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>

2..在Config Server服務端(yx-cloud-config模塊)和客戶端(消費者)(yx-service-page模塊)的yml配置?件中添加 rabbitmq服務的配置信息

spring:
  rabbitmq:
    host: 192.168.48.67
    username: admin
    password: 123456

3.Config Server微服務(yx-cloud-config模塊)和消費者page的application.yml?件中暴露端?

Spring Cloud之Config分布式配置應?,spring cloud,分布式,spring

?Spring Cloud之Config分布式配置應?,spring cloud,分布式,spring

?4.重啟各個服務,更改配置之后,向配置中?服務端發(fā)送POST請求,各個客戶端配置即可?動刷新http://127.0.0. 1:9400/actuator/bus-refresh。 文章來源地址http://www.zghlxwxcb.cn/news/detail-556549.html

到了這里,關于Spring Cloud之Config分布式配置應?的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • 使用Spring Cloud構(gòu)建分布式應用

    Spring Cloud是一組構(gòu)建分布式系統(tǒng)的框架,它提供了各種工具和庫,幫助開發(fā)人員構(gòu)建高可用、可伸縮、靈活的分布式應用程序。本文將介紹如何使用Spring Cloud構(gòu)建分布式應用程序。 微服務架構(gòu) Spring Cloud是基于微服務架構(gòu)設計的,該架構(gòu)將應用程序劃分為一組小型、自治的服

    2024年02月06日
    瀏覽(95)
  • Spring Cloud Sleuth:分布式鏈路跟蹤

    1.1 什么是分布式鏈路跟蹤 在分布式系統(tǒng)中,由于服務間的調(diào)用涉及多個節(jié)點和網(wǎng)絡通信,出現(xiàn)問題時追蹤問題的根源變得異常困難。分布式鏈路跟蹤是一種技術,旨在解決這個問題。它允許開發(fā)人員追蹤分布式系統(tǒng)中請求的流轉(zhuǎn)路徑,從而定位和解決性能問題、異常和錯誤

    2024年02月21日
    瀏覽(44)
  • 十六、Spring Cloud Sleuth 分布式請求鏈路追蹤

    十六、Spring Cloud Sleuth 分布式請求鏈路追蹤

    1、為什么出出現(xiàn)這個技術?需要解決哪些問題 2、是什么? 官網(wǎng): https://github.com/spring-cloud/spring-cloud-sleuth spring-cloud-sleuth 提供了一套完整的分布式鏈路追蹤的解決方案 ,并且兼容支持了 zipkin (展現(xiàn)) 3、解決 1、下載運行zipkin 下載jar包到本地 https://repo1.maven.org/maven2/io/zipkin/

    2024年02月12日
    瀏覽(27)
  • Spring Cloud——演進與應用的分布式系統(tǒng)開發(fā)利器

    Spring Cloud——演進與應用的分布式系統(tǒng)開發(fā)利器

    ??作者簡介: 花想云 ,目前大二在讀 ,C/C++領域新星創(chuàng)作者、運維領域新星創(chuàng)作者、CSDN2023新星計劃導師、CSDN內(nèi)容合伙人、阿里云專家博主、華為云云享專家 ?? 專欄推薦: C語言初階系列 、 C語言進階系列 、 C++系列 、 數(shù)據(jù)結(jié)構(gòu)與算法 、 Linux從入門到精通 ??個人聯(lián)系方

    2024年02月08日
    瀏覽(21)
  • Spring Cloud Alibaba【Nacos配置動態(tài)刷新、Nacos集群架構(gòu)介紹 、Nacos的數(shù)據(jù)持久化、認識分布式流量防護 】(五)
  • 分布式鏈路追蹤專欄,Spring Cloud Sleuth:分布式鏈路追蹤之通信模型設計

    分布式鏈路追蹤專欄,Spring Cloud Sleuth:分布式鏈路追蹤之通信模型設計

    Spring Cloud Sleuth ?賦予分布式跟蹤的 ?Spring Boot? 自動配置的一鍵解決方案。 Spring Cloud Sleuth? 是基于 ?Brave? 的封裝,也是很多公司采用開源加自研的最佳解決方案。 那么從作為架構(gòu)師或者技術專家如何去借鑒優(yōu)秀框架的設計理念和思想,本次? Chat? 將開啟作者既分布式鏈路

    2024年01月19日
    瀏覽(27)
  • # Spring Boot 中如何使用 Spring Cloud Sleuth 來實現(xiàn)分布式跟蹤?

    # Spring Boot 中如何使用 Spring Cloud Sleuth 來實現(xiàn)分布式跟蹤?

    在微服務架構(gòu)中,通常會有多個服務相互協(xié)作,為了方便排查問題,我們需要對服務之間的調(diào)用進行跟蹤。Spring Cloud Sleuth 是 Spring Cloud 生態(tài)中的分布式跟蹤解決方案,它可以幫助我們追蹤請求在微服務系統(tǒng)中的傳遞路徑,以及記錄每個服務的處理時間等信息。 本文將介紹如

    2024年02月08日
    瀏覽(42)
  • Spring Cloud微服務架構(gòu):實現(xiàn)分布式系統(tǒng)的無縫協(xié)作

    Spring Cloud微服務架構(gòu):實現(xiàn)分布式系統(tǒng)的無縫協(xié)作

    ??歡迎來到架構(gòu)設計專欄~Spring Cloud微服務架構(gòu):實現(xiàn)分布式系統(tǒng)的無縫協(xié)作 ☆* o(≧▽≦)o *☆嗨~我是IT·陳寒?? ?博客主頁:IT·陳寒的博客 ??該系列文章專欄:架構(gòu)設計 ??其他專欄:Java學習路線 Java面試技巧 Java實戰(zhàn)項目 AIGC人工智能 數(shù)據(jù)結(jié)構(gòu)學習 ??文章作者技術和水

    2024年02月08日
    瀏覽(95)
  • Spring Cloud學習(九)【Elasticsearch 分布式搜索引擎01】

    Spring Cloud學習(九)【Elasticsearch 分布式搜索引擎01】

    Elasticsearch 是一款非常強大的開源搜索引擎,可以幫助我們從海量數(shù)據(jù)中快速找到需要的內(nèi)容。 elasticsearch 結(jié)合 kibana、Logstash、Beats,也就是 elastic stack(ELK) 。被廣泛應用在日志數(shù)據(jù)分析、實時監(jiān)控等領域。 elasticsearch 是 elastic stack 的核心,負責 存儲、搜索、分析數(shù)據(jù) 。

    2024年02月05日
    瀏覽(92)
  • 基于Spring Cloud Alibaba+Skywalking的分布式鏈路追蹤設計

    胡弦,視頻號2023年度優(yōu)秀創(chuàng)作者,互聯(lián)網(wǎng)大廠P8技術專家,Spring Cloud Alibaba微服務架構(gòu)實戰(zhàn)派(上下冊)和RocketMQ消息中間件實戰(zhàn)派(上下冊)的作者,資深架構(gòu)師,技術負責人,極客時間訓練營講師,四維口袋KVP最具價值技術專家,技術領域?qū)<覉F成員,2021電子工業(yè)出版社年度優(yōu)

    2024年04月22日
    瀏覽(42)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包