Google App Engine applications are easy to create, easy to maintain, and easy to scale as your traffic and data storage needs change. With App Engine, there are no servers to maintain. You simply upload your application and it's ready to go.

App Engine applications automatically scale based on incoming traffic. load balancing, microservices, authorization, SQL and NoSQL databases, Memcache, traffic splitting, logging, search, versioning, roll out and roll backs, and security scanning are all supported natively and are highly customizable.

App Engine's environments, the Standard Environment and the Flexible environment, support a host of programming languages, including Java, Python, PHP, NodeJS, Go, etc.. The two environments give users maximum flexibility in how their application behaves since each environment has certain strengths. Read The App Engine Environments for more information.

In this codelab, you will learn how to deploy a Spring Boot application into App Engine Standard environment on Google Cloud Platform via the web. This environment will scale down to 0 instances when no one is using it, and automatically scale up!

What you'll learn

What you'll need

How will you use this tutorial?

Read it through only Read it and complete the exercises

How would you rate your experience with building HTML/CSS web apps?

Novice Intermediate Proficient

How would you rate your experience with using Google Cloud Platform services?

Novice Intermediate Proficient

Codelab-at-a-conference setup

If you see a "request account button" at the top of the main Codelabs window, click it to obtain a temporary account. Otherwise ask one of the staff for a coupon with username/password.

These temporary accounts have existing projects that are set up with billing so that there are no costs associated for you with running this codelab.

Note that all these accounts will be disabled soon after the codelab is over.

Use these credentials to log into the machine or to open a new Google Cloud Console window Accept the new account Terms of Service and any updates to Terms of Service.

Here's what you should see once logged in:

When presented with this console landing page, please select the only project available. Alternatively, from the console home page, click on "Select a Project" :

Google Cloud Shell

While Google Cloud and Kubernetes can be operated remotely from your laptop, in this codelab we will be using Google Cloud Shell, a command line environment running in the Cloud.

Activate Google Cloud Shell

From the GCP Console click the Cloud Shell icon on the top right toolbar:

Then click "Start Cloud Shell":

It should only take a few moments to provision and connect to the environment:

This virtual machine is loaded with all the development tools you'll need. It offers a persistent 5GB home directory, and runs on the Google Cloud, greatly enhancing network performance and authentication. Much, if not all, of your work in this lab can be done with simply a browser or your Google Chromebook.

Once connected to Cloud Shell, you should see that you are already authenticated and that the project is already set to your PROJECT_ID.

Run the following command in Cloud Shell to confirm that you are authenticated:

gcloud auth list

Command output

Credentialed accounts:
 - <myaccount>@<mydomain>.com (active)
gcloud config list project

Command output

project = <PROJECT_ID>

If it is not, you can set it with this command:

gcloud config set project <PROJECT_ID>

Command output

Updated property [core/project].

After Cloud Shell launches, you can use the command line to generate a new Spring Boot

application with Spring initializr:

$ curl \
  -d bootVersion=2.1.8.RELEASE \
  -d dependencies=web \
  -d baseDir=gae-standard-example | tar -xzvf -
$ cd gae-standard-example

There are multiple ways to deploy a Java server application - either by using a Maven or Gradle plugin, or by deploying the war package directory. In the code lab, we'll use Maven to deploy the application.

Add App Engine Plugin

Update the pom.xml to include a Google Cloud Platform plugin that simplifies the deployment process. You can use vim,nano,or emacs to edit the file.


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

To deploy the application into App Engine standard, you must add create a new src/main/appengine/app.yaml descriptor file:

$ mkdir -p src/main/appengine/
$ touch src/main/appengine/app.yaml

Edit src/main/appengine/app.yaml file and add the following content:


runtime: java11
instance_class: F4

Add a new controller that returns "hello" in


package com.example.demo;


// Add imports
import org.springframework.web.bind.annotation.*;

public class DemoApplication {
  public static void main(String[] args) {, args);

  public String hello() {
    return "hello world!";

You can start the Spring Boot application normally with the Spring Boot plugin:

$ ./mvnw -DskipTests spring-boot:run

Once the application started, click on the Web Preview icon in the Cloud Shell toolbar and choose preview on port 8080.

A tab in your browser opens and connects to the server you just started.

First, initialize the Project to be able to run App Engine applications. We'll initialize the project to run in the US Central region:

$ gcloud app create --region us-central
You are creating an app for project [...].
WARNING: Creating an App Engine application for a project is irreversible and the region
cannot be changed. More information about regions is at

Then, deploy your application into App Engine environment, run mvn appengine:deploy:

$ ./mvnw -DskipTests package appengine:deploy
... first time deploy may take a couple of mintues

After the application is deployed, you can visit it by opening the URL http://<project-id> in your web browser. Or, type:

$ gcloud app browse
... [It may print out the URL for your app]

In this step, you set up a simple Spring Boot application and ran and deployed your application on App Engine.

You learned how to write your first App Engine web application!

Learn More


This work is licensed under a Creative Commons Attribution 2.0 Generic License.