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

  • 適用於 Cloud Firestore 的 Spring Data Reactive 倉庫

  • Spring Data Cloud SQL

  • (原 Stackdriver) Google Cloud Logging、Tracing 和 Monitoring

  • Google Cloud Storage (Spring Resource 和 Spring Integration)

  • Google Cloud Vision API Template

  • 從 Google Cloud IAP 或 Firebase Headers 提取身份資訊的 Spring Security 支援

  • 透過 Spring Integration 整合 Google Cloud BigQuery

  • Secret Manager 屬性源和 API Template

  • KMS 金鑰加解密 API Template

開始使用

所有 Spring Cloud GCP Artifact 都可透過 Maven Central 獲取。

材料清單 (BOM)

如果您正在使用 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>

Starter 依賴

Spring Cloud GCP 透過 Maven 提供 starter 依賴,以便輕鬆地依賴庫的不同模組。每個 starter 都包含開始使用其相應的 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 社群所有即將舉辦的活動。

檢視全部