Bootiful GCP: Getting Started With Spring Cloud for Google Cloud Platform

DZone 's Guide to

Bootiful GCP: Getting Started With Spring Cloud for Google Cloud Platform

This series on Spring Cloud integration for the Google Cloud Platform starts by setting up a simple project using Spring Cloud GCP.

· Cloud Zone ·
Free Resource

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.

In this installment, we're going to introduce Spring Cloud GCP and then set up 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 has 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 workloads. 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 set up 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 log in. Run the following command to log in 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="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">


    <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 set up a basic Spring Cloud GCP project. In the next installment, we'll look at using Spring Cloud CCP to talk to a SQL database like MySQL or PostgreSQL.

cloud ,spring cloud ,google cloud platform ,tutorial ,gcp

Published at DZone with permission of Joshua Long , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}