OpenFeign 使用教程:從入門到實踐

文章目錄

  • 一、什么是 OpenFeign?
    • 1、什么是 OpenFeign?
    • 2、什么是 Feign?
    • 3、OpenFeign 與 Feign 的關系
    • 4、為什么選擇 OpenFeign?
    • 5、總結
  • 二、OpenFeign 的使用步驟
    • 1. 導入依賴
    • 2. 啟用 OpenFeign
    • 3. 配置 Nacos
  • 三、`@FeignClient` 參數詳解
    • 1. `name` / `value`
    • 2. `url`
    • 3. `configuration`
    • 4. `fallback`
    • 5. `fallbackFactory`
    • 6. `path`
    • 7. `contextId`
  • 四、完整實例:帶 `fallbackFactory` 和 `configuration` 的 Feign 客戶端
    • 1. 引入依賴
    • 2. 配置 Nacos
    • 3. 自定義配置類-configuration
    • 4. 自定義降級工廠類
    • 5. 定義 Feign 客戶端-fallbackFactory
    • 6. 使用 `InnerAuth` 注解
    • 7. 調用 Feign 客戶端
    • 8. 驗證效果


一、什么是 OpenFeign?

OpenFeign 是一個聲明式的 Web 服務客戶端,它使得編寫 HTTP 客戶端變得更加簡單。只需要創建一個接口并添加注解,就可以完成對遠程服務的調用。OpenFeign 集成了 Ribbon 和 Hystrix(可選),支持負載均衡和服務熔斷。

在微服務架構中,服務之間的調用是常見的需求。為了簡化這種跨服務的調用,OpenFeignFeign 提供了一種聲明式的 HTTP 客戶端解決方案。本文將詳細介紹 OpenFeign 的簡介,并深入探討它與 Feign 的關系。


1、什么是 OpenFeign?

OpenFeign 是 Spring Cloud 生態系統中的一個組件,是對 Netflix Feign 的增強和擴展。它是一種聲明式的 Web 服務客戶端,允許開發者通過定義接口和注解的方式輕松實現對遠程服務的調用。

核心特點:

  1. 聲明式接口:通過簡單的接口和注解(如 @FeignClient)定義服務調用邏輯,無需手動編寫 HTTP 請求代碼。
  2. 集成 Spring:OpenFeign 深度集成了 Spring 框架,支持 Spring 的依賴注入、配置管理等功能。
  3. 負載均衡:內置 Ribbon 支持,能夠自動實現客戶端負載均衡。
  4. 熔斷器支持:可與 Hystrix 集成,提供服務降級和熔斷功能。
  5. 靈活擴展:支持自定義攔截器、編碼器、解碼器等,滿足個性化需求。

2、什么是 Feign?

Feign 是由 Netflix 開發的一個輕量級 HTTP 客戶端庫,它最初設計用于簡化 RESTful API 的調用。Feign 的核心思想是通過定義接口和注解的方式,將 HTTP 請求抽象為 Java 接口方法調用。

核心特點:

  1. 聲明式接口:與 OpenFeign 類似,Feign 也通過接口和注解定義服務調用邏輯。
  2. 輕量化:Feign 是一個獨立的庫,不依賴于任何框架。
  3. 可插拔性:支持多種編碼器、解碼器和日志記錄器,可以根據需要進行擴展。
  4. 社區活躍:雖然 Netflix 已停止維護 Feign,但其開源版本仍然被廣泛使用。

3、OpenFeign 與 Feign 的關系

  1. 繼承與擴展
  • OpenFeign 是基于 Feign 的擴展版本,它繼承了 Feign 的核心功能,并在此基礎上增加了對 Spring Cloud 生態的支持。
  • Feign 是一個獨立的 HTTP 客戶端庫,而 OpenFeign 則是 Spring Cloud 對 Feign 的封裝和增強。
  1. Spring Cloud 的整合
  • Feign:是一個通用的 HTTP 客戶端,適用于任何 Java 應用程序,但它本身并不與 Spring 框架深度集成。
  • OpenFeign:專門為 Spring Cloud 設計,提供了與 Spring 的無縫集成能力。例如,支持 Spring 的依賴注入、配置文件管理、負載均衡(Ribbon)、服務發現(Eureka/Nacos)以及熔斷器(Hystrix)等功能。
  1. 功能對比
功能FeignOpenFeign
Spring 集成不支持支持
負載均衡需要手動配置內置 Ribbon 支持
服務發現需要手動實現支持 Eureka/Nacos 等注冊中心
熔斷器支持需要手動集成 Hystrix內置 Hystrix 支持
日志級別配置需要手動配置支持 Spring 的日志配置
社區維護Netflix 停止維護Spring 社區持續維護
  1. 代碼差異
  • 使用 Feign
import feign.Feign;
import feign.Logger;
import feign.gson.GsonDecoder;public class FeignExample {public static void main(String[] args) {ExampleClient client = Feign.builder().decoder(new GsonDecoder()).logger(new Logger.ErrorLogger()).logLevel(Logger.Level.BASIC).target(ExampleClient.class, "http://example.com");String response = client.getData("param");System.out.println(response);}
}interface ExampleClient {@RequestLine("GET /api/example?param={param}")String getData(@Param("param") String param);
}
  • 使用 OpenFeign
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;@FeignClient(name = "example-service", url = "http://example.com")
public interface ExampleClient {@GetMapping("/api/example")String getData(@RequestParam("param") String param);
}

從代碼可以看出:

  • Feign 的配置更加繁瑣,需要手動設置解碼器、日志記錄器等。
  • OpenFeign 利用了 Spring 的特性,配置更加簡潔,且支持注解驅動。

4、為什么選擇 OpenFeign?

  1. 更強大的生態支持
    OpenFeign 作為 Spring Cloud 的一部分,能夠無縫集成 Spring 的各種功能,如負載均衡、服務發現、熔斷器等。

  2. 更高的開發效率
    OpenFeign 的聲明式接口和注解方式極大地簡化了服務調用的開發過程,減少了手動編寫 HTTP 請求代碼的工作量。

  3. 更好的社區維護
    雖然 Feign 已經停止維護,但 OpenFeign 作為 Spring Cloud 的一部分,得到了 Spring 社區的持續支持和更新。

  4. 更適合微服務架構
    OpenFeign 專為微服務設計,能夠輕松應對服務間的復雜調用場景。


5、總結

Feign 是一個輕量級的 HTTP 客戶端庫,適合簡單的 RESTful API 調用。而 OpenFeign 是 Feign 的增強版,專注于微服務架構,深度集成了 Spring Cloud 生態,提供了更強大的功能和更高的開發效率。

如果你正在使用 Spring Cloud 構建微服務架構,那么 OpenFeign 是一個更好的選擇;而如果你需要一個獨立的 HTTP 客戶端庫,Feign 仍然是一個不錯的選擇。

希望這篇博客能幫助你更好地理解 OpenFeign 和 Feign 的關系!如果有任何問題,歡迎隨時交流!


二、OpenFeign 的使用步驟

1. 導入依賴

在使用 OpenFeign 之前,需要確保項目中已經引入了相關的依賴。以下是 Maven 項目的依賴配置:

<!-- Spring Boot Starter -->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency><!-- Spring Cloud OpenFeign -->
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency><!-- Nacos 作為注冊中心 -->
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>

同時,確保在 pom.xml 中指定了 Spring Cloud 的版本,例如:

<dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>2022.0.3</version> <!-- 根據實際情況選擇版本 --><type>pom</type><scope>import</scope></dependency></dependencies>
</dependencyManagement>

2. 啟用 OpenFeign

在 Spring Boot 的啟動類上添加 @EnableFeignClients 注解,以啟用 OpenFeign 功能:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;@SpringBootApplication
@EnableFeignClients // 啟用 Feign 客戶端
public class Application {public static void main(String[] args) {SpringApplication.run(Application.class, args);}
}

3. 配置 Nacos

application.yml 中配置 Nacos 作為注冊中心:

spring:application:name: consumer-service # 當前服務名稱cloud:nacos:discovery:server-addr: localhost:8848 # Nacos 地址
server:port: 8081

三、@FeignClient 參數詳解

好的!下面我們將詳細講解 @FeignClient 注解的參數,并結合 Nacos 作為配置中心和注冊中心的實際場景,給出完整的實例。

@FeignClient 是 OpenFeign 的核心注解,用于聲明一個 Feign 客戶端。以下是其常用參數的詳細說明:

1. name / value

  • 作用:指定服務名稱,通常與注冊中心(如 Nacos)中的服務名一致。

  • 示例

    @FeignClient(name = "example-service")
    public interface ExampleClient {@GetMapping("/api/example")String getExampleData(@RequestParam("param") String param);
    }
    

    在上述代碼中,name = "example-service" 表示該客戶端會調用名為 example-service 的服務。


2. url

  • 作用:指定服務的直接 URL(如果未使用注冊中心)。

  • 注意:當使用注冊中心(如 Nacos)時,通常不需要顯式指定 url,因為服務發現機制會自動解析服務地址,也可以不用name只用url,這樣就不走注冊中心,直接使用url訪問。

  • 示例

    @FeignClient(name = "example-service", url = "http://localhost:8080")
    public interface ExampleClient {@GetMapping("/api/example")String getExampleData(@RequestParam("param") String param);
    }
    

3. configuration

  • 作用:自定義 Feign 客戶端的配置類。

  • 用途:可以自定義攔截器、編碼器、解碼器等。

  • 示例
    首先,創建一個自定義配置類:

    import feign.Logger;
    import org.springframework.context.annotation.Bean;public class FeignConfig {@BeanLogger.Level feignLoggerLevel() {return Logger.Level.FULL; // 設置日志級別為 FULL}
    }
    

    然后,在 @FeignClient 中引用該配置類:

    @FeignClient(name = "example-service", configuration = FeignConfig.class)
    public interface ExampleClient {@GetMapping("/api/example")String getExampleData(@RequestParam("param") String param);
    }
    

4. fallback

  • 作用:指定熔斷器的降級處理類。

  • 用途:當遠程服務不可用時,提供備用邏輯。

  • 示例
    創建一個降級類:

    import org.springframework.stereotype.Component;@Component
    public class ExampleClientFallback implements ExampleClient {@Overridepublic String getExampleData(String param) {return "Fallback response for param: " + param;}
    }
    

    @FeignClient 中引用降級類:

    @FeignClient(name = "example-service", fallback = ExampleClientFallback.class)
    public interface ExampleClient {@GetMapping("/api/example")String getExampleData(@RequestParam("param") String param);
    }
    

5. fallbackFactory

  • 作用:指定熔斷器的降級工廠類。

  • 優點:相比 fallback,可以捕獲異常信息。

  • 示例
    創建一個降級工廠類:

    import feign.hystrix.FallbackFactory;
    import org.springframework.stereotype.Component;@Component
    public class ExampleClientFallbackFactory implements FallbackFactory<ExampleClient> {@Overridepublic ExampleClient create(Throwable cause) {return new ExampleClient() {@Overridepublic String getExampleData(String param) {return "Fallback response due to: " + cause.getMessage();}};}
    }
    

    @FeignClient 中引用降級工廠類:

    @FeignClient(name = "example-service", fallbackFactory = ExampleClientFallbackFactory.class)
    public interface ExampleClient {@GetMapping("/api/example")String getExampleData(@RequestParam("param") String param);
    }
    

6. path

  • 作用:指定基礎路徑,所有接口方法都會繼承該路徑。

  • 示例

    @FeignClient(name = "example-service", path = "/api/v1")
    public interface ExampleClient {@GetMapping("/example")String getExampleData(@RequestParam("param") String param);
    }
    

    上述代碼中,實際請求路徑為 /api/v1/example


7. contextId

  • 作用:指定上下文 ID,用于區分多個同名的 Feign 客戶端。

  • 場景:當項目中有多個同名的 Feign 客戶端時,需要通過 contextId 區分。

  • 示例

    @FeignClient(name = "example-service", contextId = "client1")
    public interface ExampleClient1 {@GetMapping("/api/example")String getExampleData(@RequestParam("param") String param);
    }@FeignClient(name = "example-service", contextId = "client2")
    public interface ExampleClient2 {@GetMapping("/api/example")String getExampleData(@RequestParam("param") String param);
    }
    

四、完整實例:帶 fallbackFactoryconfiguration 的 Feign 客戶端

以下是一個完整的實例,包含以下功能:

  1. 使用 fallbackFactory 實現服務降級。
  2. configuration 中添加 Token 到請求頭中。
  3. 使用 InnerAuth 注解實現內部服務認證。

1. 引入依賴

pom.xml 中添加以下依賴:

<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>

2. 配置 Nacos

application.yml 中配置 Nacos 作為注冊中心:

spring:application:name: consumer-service # 當前服務名稱cloud:nacos:discovery:server-addr: localhost:8848 # Nacos 地址
server:port: 8081

3. 自定義配置類-configuration

創建一個自定義配置類,用于向請求頭中添加 Token:

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class FeignConfig {@Beanpublic RequestInterceptor requestInterceptor() {return new RequestInterceptor() {@Overridepublic void apply(RequestTemplate template) {template.header("Authorization", "Bearer your-token");}};}
}

4. 自定義降級工廠類

創建一個降級工廠類,用于捕獲異常并返回備用響應:

import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;@Component
public class ExampleClientFallbackFactory implements FallbackFactory<ExampleClient> {@Overridepublic ExampleClient create(Throwable cause) {return new ExampleClient() {@Overridepublic String getDataFromProvider(String param) {return "Fallback response due to: " + cause.getMessage();}};}
}

5. 定義 Feign 客戶端-fallbackFactory

創建一個 Feign 客戶端,調用注冊在 Nacos 中的服務:

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;@FeignClient(name = "provider-service",configuration = FeignConfig.class,fallbackFactory = ExampleClientFallbackFactory.class
)
public interface ExampleClient {@GetMapping("/api/provider")String getDataFromProvider(@RequestParam("param") String param);
}

6. 使用 InnerAuth 注解

加了@InnerAuth注解每次會先進去到InnerAuthAspect.java處理,驗證請求頭是否為from-source,且攜帶內部標識參數inner。如果非內部請求訪問會直接拋出異常。 但是網關訪問的時候,也可以手動帶上這個from-source參數,來達到這個目的

假設我們有一個自定義的 @InnerAuth 注解,用于標記只允許內部服務調用的接口:

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface InnerAuth {
}

7. 調用 Feign 客戶端

在業務邏輯中,可以通過依賴注入的方式使用定義的 Feign 客戶端:

在控制器中使用該注解:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;@RestController
public class ConsumerController {@Autowiredprivate ExampleClient exampleClient;@InnerAuth@GetMapping("/call-provider")public String callProvider(@RequestParam("param") String param) {return exampleClient.getDataFromProvider(param);}
}

8. 驗證效果

  1. 啟動 Nacos 服務。
  2. 啟動 provider-service,確保其注冊到 Nacos。
  3. 啟動 consumer-service,調用 /call-provider 接口,驗證是否成功調用了 provider-service
  4. 模擬服務不可用,驗證 fallbackFactory 是否生效。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/pingmian/77626.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/77626.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/77626.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

藍橋杯 16.對局匹配

對局匹配 原題目鏈接 題目描述 小明喜歡在一個圍棋網站上找別人在線對弈。這個網站上所有注冊用戶都有一個積分&#xff0c;代表他的圍棋水平。 小明發現&#xff0c;網站的自動對局系統在匹配對手時&#xff0c;只會將積分差恰好是 K 的兩名用戶匹配在一起。如果兩人分差小…

C#常用LINQ

在開發時發現別人的代碼使用到了LINQ十分便捷且清晰&#xff0c;這里記錄一下常用LINQ和對應的使用。參考鏈接&#xff1a;LINQ 菜鳥教程 使用的學生類和字符串用于測試 public class Student {public int StudentID;public string StudentName;public int Age; }Student[] st…

單例模式(線程安全)

1.什么是單例模式 單例模式&#xff08;Singleton Pattern&#xff09;是一種創建型設計模式&#xff0c;旨在確保一個類只有一個實例&#xff0c;并提供一個全局訪問點來訪問該實例。這種模式涉及到一個單一的類&#xff0c;該類負責創建自己的對象&#xff0c;同時確保只有單…

Python 之 __file__ 變量導致打包 exe 后路徑輸出不一致的問題

現象 做項目的時候&#xff0c;一直使用 os.path.dirname(os.path.abspath(__file__)) 來獲取當前目錄。然而&#xff0c;最近卻遇到了一個路徑相關的問題。直接運行 py 文件是正常的&#xff0c;但是打包成 exe 之后&#xff0c;卻顯示因為路徑問題導致程序報錯無法繼續執行。…

PH熱榜 | 2025-04-21

1. Google Whisk 2.0 標語&#xff1a;將圖像轉換為八秒的動畫短片。 介紹&#xff1a;Whisk 是谷歌實驗室的一項新創新&#xff0c;現在推出了 Whisk Animate——它可以將你的圖片轉換成生動的8秒視頻&#xff0c;采用了 Veo 2 技術。此功能現已在60多個國家的 Google One A…

AI大模型 —— 國產大模型 —— 華為大模型

有這么一句話&#xff0c;那就是AI大模型分兩種&#xff0c;一種是大模型&#xff1b;另一種是華為大模型。 如果從技術角度來分析&#xff0c;華為的技術不論是在軟件還是硬件都比國外的大公司差距極大&#xff0c;甚至有些技術評論者認為華為的軟硬件技術至少落后2.5代&#…

FPGA 中 XSA、BIT 和 DCP 文件的區別

在 FPGA&#xff08;現場可編程門陣列&#xff09;開發中&#xff0c;XSA、BIT 和 DCP 文件是常見的文件類型&#xff0c;它們在功能、用途、文件內容等方面存在明顯區別&#xff0c;以下是詳細介紹&#xff1a; 1. XSA 文件 定義與功能 XSA&#xff08;Xilinx Shell Archiv…

MH2103系列coremark1.0跑分數據和優化,及基于arm2d的優化應用

CoreMark 1.0 介紹 CoreMark 是由 EEMBC&#xff08;Embedded Microprocessor Benchmark Consortium&#xff09;組織于 2009 年推出的一款用于衡量嵌入式系統 CPU 或 MCU 性能的標準基準測試工具。它旨在替代陳舊的 Dhrystone 標準&#xff08;Dhrystone 容易受到各種libc不同…

云原生與AI的關系是怎么樣的?

云原生與AI的結合正在重塑現代應用的開發與部署模式&#xff0c;兩者相輔相成&#xff0c;共同推動技術創新與產業升級。以下是兩者的核心概念、結合點及未來趨勢的詳細解析&#xff1a; 一、云原生與AI的核心概念 云原生&#xff08;Cloud Native&#xff09; ? 定義&#…

【CentOs】構建云服務器部署環境

(一) 服務器采購 2 CPU4G 內存40G 系統盤 80G 數據盤 (二) 服務器安全組和端口配置 (三) 磁盤掛載 1 登錄 root 2 查看目前磁盤使用情況 df -h 3 查看磁盤掛載情況 識別哪些磁盤沒掛載 fdisk -l 4 對未掛載磁盤做分區 fdisk /dev/vdb 輸入m&#xff0…

LangChain4j語言模型選型指南:主流模型能力全景對比

LangChain4j語言模型選型指南&#xff1a;主流模型能力全景對比 前言 在大語言模型應用開發中&#xff0c;選擇合適的底層模型提供商是架構設計的關鍵決策。LangChain4j作為Java生態的重要AI框架&#xff0c;其支持的20模型提供商各有獨特的優勢場景。本文通過功能矩陣深度解…

2025.4.21日學習筆記 JavaScript String、Array、date、math方法的使用

1. String&#xff08;字符串&#xff09; String 對象用于處理和操作文本數據。 length&#xff1a;返回字符串的長度。 const str "Hello"; console.log(str.length); // 輸出: 5 charAt(index)&#xff1a;返回指定索引位置的字符。 const str "Hello…

(14)VTK C++開發示例 --- 將點投影到平面上

文章目錄 1. 概述2. CMake鏈接VTK3. main.cpp文件4. 演示效果 更多精彩內容&#x1f449;內容導航 &#x1f448;&#x1f449;VTK開發 &#x1f448; 1. 概述 計算一個點在一個平面上的投影。 vtkPlane 是 VTK&#xff08;Visualization Toolkit&#xff09;庫中的一個類&…

電子電器架構 ---軟件定義汽車的電子/電氣(E/E)架構

我是穿拖鞋的漢子,魔都中堅持長期主義的汽車電子工程師。 老規矩,分享一段喜歡的文字,避免自己成為高知識低文化的工程師: 周末洗了一個澡,換了一身衣服,出了門卻不知道去哪兒,不知道去找誰,漫無目的走著,大概這就是成年人最深的孤獨吧! 舊人不知我近況,新人不知我過…

Android開發中的復制和粘貼

Android 提供了一個強大的基于剪貼板的框架&#xff0c;用于復制和粘貼。它支持簡單和復雜的數據類型&#xff0c;包括文本字符串、復雜數據結構、文本和二進制流數據&#xff0c;以及應用資源。簡單的文本數據直接存儲在剪貼板中&#xff0c;而復雜的數據則存儲為引用&#xf…

【STM32單片機】#10.5 串口數據包

主要參考學習資料&#xff1a; B站江協科技 STM32入門教程-2023版 細致講解 中文字幕 開發資料下載鏈接&#xff1a;https://pan.baidu.com/s/1h_UjuQKDX9IpP-U1Effbsw?pwddspb 單片機套裝&#xff1a;STM32F103C8T6開發板單片機C6T6核心板 實驗板最小系統板套件科協 實驗&…

百度暑期實習崗位超3000個,AI相關崗位占比87%,近嶼智能攜AIGC課程加速人才輸出

今年3月&#xff0c;百度重磅發布3000暑期實習崗位&#xff0c;聚焦大模型、機器學習、自動駕駛等AI方向的崗位比例高達87%。此次實習崗位涉及技術研發、產品策劃、專業服務、管理支持、政企解決方案等四大類別&#xff0c;覆蓋超300個崗位細分方向。值得一提的是&#xff0c;百…

vue3 + element-plus中el-dialog對話框滾動條回到頂部

對話框滾動條回到頂部 1、需要對話框顯示后 2、使用 nextTick 等待 Dom 更新完畢 3、通過開發者工具追查到滾動條對應的標簽及class“el-overlay-dialog” 4、設置屬性 scrollTop 0 或者 執行方法 scrollTo(0, 0) // 對話框顯示標識 const dialogVisible ref(false); //…

C++學習之游戲服務器開發十一DOCKER的基本使用

目錄 1.多實例部署方案 2.容器的概念 3.docker初識 4.docker倉庫 5.docker鏡像 6.docker容器 7.docker和虛擬機的區別 8.docker命令解釋 9.dockerfile構建鏡像 10.離線分發鏡像 1.多實例部署方案 redis 命令&#xff08; redis-cli XXXX &#xff09; set key value:…

2025.4.21總結

工作&#xff1a;開了一場關于大模型版本的會議&#xff0c;回歸一個問題單&#xff0c;提了兩個單&#xff0c;把用例都執行完。如今都四月中旬了&#xff0c;上班年快要結束了&#xff0c;該到了沖刺KPI的時候了。 今日思考&#xff1a;刷到了jack叔叔的視頻&#xff0c;講了…