Deploying Spring Boot Applications in the Google AppEngine Flex Environment

No Comments

In this tutorial I will show how to set up a deployment of Spring Boot applications for the AppEngine Flex environment in the Google Cloud infrastructure.


You should be familiar with the Spring Boot ecosystem and should be able to use Maven as a build tool.

Preparations for Google AppEngine Development

There are several general steps to go through in order to be able to deploy an application to the AppEngine environment.

  • Create a Google Cloud account and set up billing.
  • Create a new project. Accept the proposed project ID or choose your own. We will use the expression [PROJECT_ID] for the rest of this tutorial.
  • Download and install the GCP Cloud SDK.
  • Initialize the Cloud SDK so it points to your GCP project:
gcloud init [PROJECT_ID]

Spring Boot Demo Application

With the new AppEngine Flex Environment you are no longer restricted to the Jetty web framework in order to run web applications. So there is no need to tweak your Spring Boot dependencies in order to run in the GAE any more. (Check the differences between the standard and the flex environment.)

Our first Spring Boot application will feature a very simple REST controller:

public class HelloController {
    public String hello() { return "Hello AppEngine Flex"; }

Since the AppEngine performs a health check by default, we are using the actuator starter and bind it to the required path in src/main/resources/application.yml:

   context-path: /_ah
    enabled: false

For the sake of simplicity we are using the GAE legacy health check that will perform a GET request to /_ah/health.

AppEngine Flex Deployment

The AppEngine deployment descriptor has to be located in src/main/appengine/app.yaml. These are the most important settings:

service: sb-gcp # Id of the service
env: flex       # Flex environment
runtime: java   # Java runtime
  jdk: openjdk8 # use OpenJDK 8

Your project holds several services. Each service needs a unique identifier that is set by the service parameter. Then we configure the flex environment and the Java runtime.

In order to deploy the Spring Boot application, we are using this Maven plugin:

<!-- AppEngine -->

Now we are ready to build a deployment:

mvn clean package appengine:deploy

The last Maven goal triggers the deployment which in the end is performed by the gcloud command line client from the Cloud SDK. This will run for some time. Basically, a Docker image containing your Spring Boot JAR is built and deployed to the GCP. After deploymemt is finally finished, your application will show up in the

AppEngine Dashboard

Each deployment creates a new version of a service. Our AppEngine dashboard for the service named sb-gcp may look like this:

appengine-flex versions

You can start and stop your service, go back to older versions etc.

And finally we see our running application at


That’s the output from our simple REST controller:

curl https://sb-gcp-dot-[PROJECT_ID].appspot.com/hello
Hello AppEngine Flex

What’s next?

In upcoming posts I’ll show you how to access backends in the Google Compute Engine from Spring Boot applications.


Your email address will not be published. Required fields are marked *