Spring Cloud GCPSpring Cloud GCP

Spring Cloud GCP 專案使 Spring Framework 成為 Google Cloud Platform (GCP) 的一等公民。

Spring Cloud GCP 不再是 Spring Cloud 釋出列車的一部分。新的倉庫位置是 https://github.com/GoogleCloudPlatform/spring-cloud-gcp。如果您正在從 1.x 版本升級,請檢視遷移指南,瞭解如何從 1.x 版本升級到 2.0.0(或更高版本)。

特性

Spring Cloud GCP 提供了一系列豐富的庫,使從 Spring Framework 應用程式中使用 Google Cloud Platform 變得更加容易。

專案功能包括

  • Spring Cloud GCP Pub/Sub 支援 (Spring Integration 和 Spring Cloud Stream Binder)

  • Spring Data Cloud Spanner

  • Spring Data Cloud Datastore

  • Spring Data Reactive Repositories for Cloud Firestore

  • Spring Data Cloud SQL

  • Google Cloud Logging、Tracing 和 Monitoring(以前稱為 Stackdriver)

  • Google Cloud Storage (Spring Resource 和 Spring Integration)

  • Google Cloud Vision API 模板

  • 從 Google Cloud IAP 或 Firebase 標頭中提取 Spring Security 身份

  • Google Cloud BigQuery 與 Spring Integration

  • Secret Manager 屬性源和 API 模板

  • KMS 金鑰加密/解密 API 模板

入門

所有 Spring Cloud GCP 構件都透過 Maven Central 提供。

物料清單 (Bill of Materials)

如果您使用 Maven,您應該首先將 Spring Cloud GCP 物料清單 (BOM) 新增到您的 pom.xml 中。這將幫助您管理專案中 spring-cloud-gcp 依賴項的版本號。

<dependencyManagement>
   <dependencies>
       <dependency>
           <groupId>com.google.cloud</groupId>
           <artifactId>spring-cloud-gcp-dependencies</artifactId>
           <version>${spring-cloud-gcp.version}</version>
           <type>pom</type>
           <scope>import</scope>
       </dependency>
   </dependencies>
</dependencyManagement>

啟動器依賴項

Spring Cloud GCP 透過 Maven 提供啟動器依賴項,以便輕鬆地依賴庫的不同模組。每個啟動器都包含開始使用其相應的 Spring Cloud GCP 模組所需的所有依賴項和傳遞依賴項。

程式碼示例

學習如何使用 Spring Cloud GCP 的最佳方法是查閱 Github 上的示例應用程式

下表重點介紹了 Spring Cloud GCP 中最常用整合的一些示例。

GCP 整合 示例應用程式
Cloud Pub/Sub spring-cloud-gcp-pubsub-sample
Cloud Spanner spring-cloud-gcp-data-spanner-sample
Cloud Datastore spring-cloud-gcp-data-datastore-sample
Cloud Firestore spring-cloud-gcp-data-firestore-sample
Cloud SQL (帶 MySQL) spring-cloud-gcp-sql-mysql-sample
Cloud Storage spring-cloud-gcp-storage-resource-sample
Google Cloud Logging spring-cloud-gcp-logging-sample
Google Cloud Tracing spring-cloud-gcp-trace-sample
Cloud Vision spring-cloud-gcp-vision-api-sample
Cloud Security - IAP spring-cloud-gcp-security-iap-sample

Initializr

Spring Initializr 是一個為新的 Spring Boot 專案生成骨架程式碼的工具。它負責生成 Maven 或 Gradle 構建檔案,因此您無需手動新增依賴項。

Spring Initializr 提供了 Spring Cloud GCP 的三個模組,您可以使用它們來生成您的專案。

  • GCP Support:GCP Support 模組包含對每個 Spring Cloud GCP 整合的自動配置支援。大多數自動配置程式碼僅在將所需的依賴項新增到您的專案時才啟用。

  • GCP Messaging:Google Cloud Pub/Sub 整合開箱即用。

  • GCP Storage:Google Cloud Storage 整合開箱即用。

聯絡我們

Spring Cloud GCP 是一個積極維護的專案,我們鼓勵使用者提出問題和疑問。

我們積極監控以下溝通渠道

Spring Initializr

快速啟動您的專案

領先一步

VMware 提供培訓和認證,助您加速進步。

瞭解更多

獲得支援

Tanzu Spring 提供 OpenJDK™、Spring 和 Apache Tomcat® 的支援和二進位制檔案,只需一份簡單的訂閱。

瞭解更多

即將舉行的活動

檢視 Spring 社群所有即將舉行的活動。

檢視所有