close

Spring Cloud GCP

1.2.4

The Spring Cloud GCP project makes the Spring Framework a first-class citizen of Google Cloud Platform (GCP).

Features

Spring Cloud GCP offers a wide collection of libraries that make it easier to use Google Cloud Platform from Spring Framework applications.

Project features include:

  • Spring Cloud GCP Pub/Sub Support (Spring Integration and 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 Stackdriver Logging & Tracing

  • Google Cloud Storage (Spring Resource and Spring Integration)

  • Google Cloud Vision API Template

  • Spring Security identity extraction from Google Cloud IAP headers.

  • Google Cloud BigQuery with Spring Integration

Getting Started

All Spring Cloud GCP artifacts are made available through Maven Central.

Bill of Materials

If you’re using Maven, you should first add the Spring Cloud GCP Bill of Materials (BOM) to your pom.xml. This will help you manage the version numbers of spring-cloud-gcp dependencies in your project.

<dependencyManagement>
   <dependencies>
       <dependency>
           <groupId>org.springframework.cloud</groupId>
           <artifactId>spring-cloud-gcp-dependencies</artifactId>
           <version>{project-version}</version>
           <type>pom</type>
           <scope>import</scope>
       </dependency>
   </dependencies>
</dependencyManagement>

Starter Dependencies

Spring Cloud GCP offers starter dependencies through Maven to easily depend on different modules of the library. Each starter contains all the dependencies and transitive dependencies needed to begin using their corresponding Spring Cloud GCP module.

A sample of these artifacts are provided below.

Spring Cloud GCP Starter Description Maven Artifact Coordinates

Cloud Spanner

Provides integrations with Google Cloud Spanner

org.springframework.cloud:spring-cloud-gcp-starter-data-spanner

Cloud Datastore

Provides integrations with Google Cloud Datastore

org.springframework.cloud:spring-cloud-gcp-starter-data-datastore

Cloud Firestore

Provides Spring Data Reactive Repositories support for Cloud Firestore

org.springframework.cloud:spring-cloud-gcp-starter-data-firestore

Cloud Pub/Sub

Provides integrations with Google Cloud Pub/Sub

org.springframework.cloud:spring-cloud-gcp-starter-pubsub

Logging

Enables Stackdriver Logging

org.springframework.cloud:spring-cloud-gcp-starter-logging

SQL - MySQL

Cloud SQL integrations with MySQL

org.springframework.cloud:spring-cloud-gcp-starter-sql-mysql

SQL - PostgreSQL

Cloud SQL integrations with PostgreSQL

org.springframework.cloud:spring-cloud-gcp-starter-sql-postgresql

Storage

Provides integrations with Google Cloud Storage and Spring Resource

org.springframework.cloud:spring-cloud-gcp-starter-storage

Trace

Enables instrumentation with Google Stackdriver Tracing

org.springframework.cloud:spring-cloud-gcp-starter-trace

Vision

Provides integrations with Google Cloud Vision

org.springframework.cloud:spring-cloud-gcp-starter-vision

Security - IAP

Extracts IAP identity information from applications deployed to Google Cloud

org.springframework.cloud:spring-cloud-gcp-starter-security-iap

Code Samples

The best way to learn how to use Spring Cloud GCP is to consult the sample applications on Github.

The table below highlights several samples of the most commonly used integrations in Spring Cloud GCP.

GCP Integration Sample Application

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 (w/ MySQL)

spring-cloud-gcp-sql-mysql-sample

Cloud Storage

spring-cloud-gcp-storage-resource-sample

Stackdriver Logging

spring-cloud-gcp-logging-sample

Trace

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 is a tool which generates the scaffolding code for a new Spring Boot project. It handles the work of generating the Maven or Gradle build file so you do not have to manually add the dependencies yourself.

Spring Initializr offers three modules from Spring Cloud GCP that you can use to generate your project.

  • GCP Support: The GCP Support module contains auto-configuration support for every Spring Cloud GCP integration. Most of the autoconfiguration code is only enabled if the required dependency is added to your project.

  • GCP Messaging: Google Cloud Pub/Sub integrations work out of the box.

  • GCP Storage: Google Cloud Storage integrations work out of the box.

Contact Us

Spring Cloud GCP is an actively maintained project and we encourage users to raise issues and ask questions about the project.

We actively monitor the following communication channels:

Spring Initializr

Quickstart Your Project

Bootstrap your application with Spring Initializr.

Documentation

Each Spring project has its own; it explains in great details how you can use project features and what you can achieve with them.
1.2.4 SNAPSHOT CURRENT Reference Doc. API Doc.
1.2.3 CURRENT GA Reference Doc. API Doc.
1.1.5 SNAPSHOT Reference Doc. API Doc.
1.1.4 GA Reference Doc. API Doc.
1.0.0 GA Reference Doc. API Doc.

A few examples to try out: