Bootiful GCP: Getting Started with Spring Cloud for Google Cloud Platform (1/8)

Engineering | Josh Long | August 19, 2018 | ...

Hi Spring fans! In this brief 8 part series we’re going to look at the Spring Cloud integration for Google Cloud Platform, called Spring Cloud GCP. Spring Cloud GCP represents a joint effort between Google and Pivotal that endeavors to provide a first class experience for Spring Cloud developers when using the Google Cloud Platform. Pivotal Cloud Foundry users will enjoy an even easier integration with the GCP service broker. I wrote these installments with input from Google Cloud Developer Advocate, and my buddy, Ray Tsang. You can also catch a walkthrough of Spring Cloud GCP in our Google Next 2018 session, Bootiful Google Cloud Platform. Thanks buddy! As always, I'd love to hear from you if you have feedback.

There are eight posts in the series. Here they all are:


  • [Bootiful GCP: Use Spring Cloud GCP to Connect to Other GCP Services (7/8)


In this installment we’re going to introduce Spring Cloud GCP and then setup a trivial project using Spring Cloud GCP.

The Google Cloud Platform is vast! It has a ton of features. But so do the other platforms. So, why Google Cloud Platform? I’d say there are two big reasons to use GCP. First, Google’s datacenters are undoubtedly the world’s most sophisticated, and their operations acumen second to none. Let Google operate and secure your datacenter. Beyond that, Google have had to solve some amazing problems at their scale, through GCP, we can benefit from those developments on GCP. The data services, those unique to Google, are legendary. Google’s Tensorflow, for example, represents the cutting edge in machine learning, and GCP even features access to specialized An Application-Specific Integrated Circuit (ASICs) tensor processing units (TPUs) that are optimized for running TensorFlow workfloads. Google’s Spanner is the only enterprise-grade, globally-distributed, and strongly consistent database service built for the cloud specifically to combine the benefits of relational database structure with non-relational horizontal scale.


You’ll need to sign up for a GCP account. In order to use the Spring Cloud GCP project on your local machine, you’ll want to setup a project on GCP and have the gcloud CLI installed locally.

There are a few things to know and do before starting any work with GCP. First, you’ll need to login. Run the following command to login to GCP:

gcloud auth application-default login

This will make it easy to provide default credentials supporting work your interactions with the platform. In this case, you’re saying that you want to allow certain operations on your behalf.

Some operations endure independent of a particular user. They might need granular permissions that represent a subset of your privilege. They might be run independent of a given user, as in a batch job or something that runs nightly. In this case, it makes sense to use a service account. We’ll need to configure a service account later when we look at tracing.

It’s useful to know your Project ID. You’ll find a lot of incantations need to know this value. I have a little script like this that is run in my ~/.bashrc and is contributed to every shell.

export PROJECT_ID=$(gcloud config list --format 'value(core.project)')

I tend to stick to the CLI in these examples, but most everything you want to do can be done from the web console, too.

Getting Started with Spring Cloud GCP

You’ll need, at least for now, the Spring Cloud and Spring Cloud GCP bill of materials (BOM) artifacts. The easiest way to get a new Spring Cloud GCP project going is to generate a new project from the Spring Initializr and choose GCP Support. Here’s what a minimal pom.xml artifact looks like.

A basic pom.xml for Spring Cloud GCP.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""


    <description>Demo project for Spring Boot</description>

        <relativePath/> <!-- lookup parent from repository -->






            <name>Spring Milestones</name>


In this installment we've looked at how to setup a basic Spring Cloud GCP project. In the next installment, this Thursday, we'll look at using Spring Cloud CCP to talk to a SQL database like MySQL or PostgreSQL.

Get the Spring newsletter

Thank you!

Get ahead

VMware offers training and certification to turbo-charge your progress.

Learn more

Get support

Spring Runtime offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.

Learn more

Upcoming events

Check out all the upcoming events in the Spring community.

View all