Getting Started

This section describes how to get up to speed with Spring Framework on Google Cloud libraries.

Compatibility with Spring Project Versions

Spring Framework on Google Cloud has dependency and transitive dependencies on Spring Projects. The table below outlines the versions of Spring Cloud, Spring Boot and Spring Framework versions that are compatible with certain Spring Framework on Google Cloud version.

Spring Framework on Google Cloud Spring Cloud Spring Boot Spring Framework

2.x

2020.0.x (3.0/Illford)

2.4.x, 2.5.x

5.3.x

3.x

2021.0.x (3.1/Jubilee)

2.6.x, 2.7.x

5.3.x

4.x

2022.0.x (4.0/Kilburn)

3.0.x,3.1.x

6.0.x

Setting up Dependencies

All Spring Framework on Google Cloud artifacts are made available through Maven Central. The following resources are provided to help you setup the libraries for your project:

  • Maven Bill of Materials for dependency management

  • Starter Dependencies for depending on Spring Framework on Google Cloud modules

You may also consult our Github project to examine the code or build directly from source.

Bill of Materials

The Spring Framework on Google Cloud Bill of Materials (BOM) contains the versions of all the dependencies it uses.

If you’re a Maven user, adding the following to your pom.xml file will allow you omit any Spring Framework on Google Cloud dependency version numbers from your configuration. Instead, the version of the BOM you’re using determines the versions of the used dependencies.

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

Or, if you’re a Gradle user:

dependencies {
    implementation platform("com.google.cloud:spring-cloud-gcp-dependencies:4.1.3")
}

In the following sections, it will be assumed you are using the Spring Framework on Google Cloud BOM and the dependency snippets will not contain versions.

Starter Dependencies

Spring Framework on Google Cloud 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 Framework on Google Cloud module.

For example, if you wish to write a Spring application with Cloud Pub/Sub, you would include the spring-cloud-gcp-starter-pubsub dependency in your project. You do not need to include the underlying spring-cloud-gcp-pubsub dependency, because the starter dependency includes it.

A summary of these artifacts are provided below.

Aside from these modules, we also provide additional starters with auto-configurations to various Google Client Libraries. Refer for the full list here.

Spring Framework on Google Cloud Starter Description Maven Artifact Name

Core

Automatically configure authentication and Google project settings

com.google.cloud:spring-cloud-gcp-starter

Cloud Spanner

Provides integrations with Google Cloud Spanner

com.google.cloud:spring-cloud-gcp-starter-data-spanner

Cloud Datastore

Provides integrations with Google Cloud Datastore

com.google.cloud:spring-cloud-gcp-starter-data-datastore

Cloud Pub/Sub

Provides integrations with Google Cloud Pub/Sub

com.google.cloud:spring-cloud-gcp-starter-pubsub

Logging

Enables Cloud Logging

com.google.cloud:spring-cloud-gcp-starter-logging

SQL - MySQL

Cloud SQL integrations with MySQL

com.google.cloud:spring-cloud-gcp-starter-sql-mysql

SQL - PostgreSQL

Cloud SQL integrations with PostgreSQL

com.google.cloud:spring-cloud-gcp-starter-sql-postgresql

Storage

Provides integrations with Google Cloud Storage and Spring Resource

com.google.cloud:spring-cloud-gcp-starter-storage

Config

Enables usage of Google Runtime Configuration API as a Spring Cloud Config server

com.google.cloud:spring-cloud-gcp-starter-config

Trace

Enables instrumentation with Google Cloud Trace

com.google.cloud:spring-cloud-gcp-starter-trace

Vision

Provides integrations with Google Cloud Vision

com.google.cloud:spring-cloud-gcp-starter-vision

Security - IAP

Provides a security layer over applications deployed to Google Cloud

com.google.cloud:spring-cloud-gcp-starter-security-iap

Security - Firebase

Provides a security layer over applications deployed to Firebase

com.google.cloud:spring-cloud-gcp-starter-security-firebase

Spring 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 Framework on Google Cloud that you can use to generate your project.

  • GCP Support: The GCP Support module contains auto-configuration support for every Spring Framework on Google Cloud 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.

Learning Spring Framework on Google Cloud

There are a variety of resources to help you learn how to use Spring Framework on Google Cloud libraries.

Sample Applications

The easiest way to learn how to use Spring Framework on Google Cloud is to consult the sample applications on Github. Spring Framework on Google Cloud provides sample applications which demonstrate how to use every integration in the library. The table below highlights several samples of the most commonly used integrations in Spring Framework on Google Cloud.

Google Cloud Integration Sample Application

Cloud Pub/Sub

spring-cloud-gcp-pubsub-sample

Cloud Spanner

spring-cloud-gcp-data-spanner-repository-sample

spring-cloud-gcp-data-spanner-template-sample

Datastore

spring-cloud-gcp-data-datastore-sample

Cloud SQL (w/ MySQL)

spring-cloud-gcp-sql-mysql-sample

Cloud Storage

spring-cloud-gcp-storage-resource-sample

Cloud 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

Cloud Security - Firebase

spring-cloud-gcp-security-firebase-sample

Each sample application demonstrates how to use Spring Framework on Google Cloud libraries in context and how to setup the dependencies for the project. The applications are fully functional and can be deployed to Google Cloud as well. If you are interested, you may consult guides for deploying an application to AppEngine and to Google Kubernetes Engine.

Codelabs

For a more hands-on approach, there are several guides and codelabs to help you get up to speed. These guides provide step-by-step instructions for building an application using Spring Framework on Google Cloud.

Some examples include:

The full collection of Spring codelabs can be found on the Google Developer Codelabs page.