- Step 1: Install and Set Up Google Cloud SDK
- Step 2: Download a Starter App
- Step 3: Initialize a Google Cloud Project
- Step 4: Create an App Engine Instance
- Step 5: Set Up the App Engine Plugin for Maven
- Step 6: Create the app.yaml File
- Step 7: Enable Cloud Build
- Step 8: Deploy to Google App Engine
- Common Problems
This tutorial shows you how to deploy a Vaadin application to Google App Engine. Google Cloud has free-trial and free-tier offerings that you can read more about on the Google Cloud website.
Google Cloud account requiredTo complete this tutorial, you need to sign up for a Google Cloud account at https://cloud.google.com/. Your Google Cloud account should also have the billing enabled.
To begin, download and install the Google Cloud SDK.
After it is installed, run the following command from a terminal window to add App Engine support for Java to the SDK.
gcloud components install app-engine-java
Open the project directory from a terminal window, and enter the following command to initialize a Google Cloud project:
If this is your first time running Google SDK, you will be asked to authenticate your account. When prompted to log in, enter 'Y' and allow the SDK to control your account in the opened browser window.
After authentication, you will prompted to select a configuration. Enter '1' to select the default configuration, as in the following snippet:
Settings from your current configuration [default] are: accessibility: screen_reader: 'False' core: account: email@example.com disable_usage_reporting: 'True' Pick configuration to use:  Re-initialize this configuration [default] with new settings  Create a new configuration Please enter your numeric choice: 1
From a terminal window, in the project root directory, create a Google App Engine instance using the following command:
gcloud app create
You will then be asked to select a region. You may want to choose the region that is geographically closest to your users.
Add the App Engine Maven plugin to your project’s pom.xml file.
<plugin> <groupId>com.google.cloud.tools</groupId> <artifactId>appengine-maven-plugin</artifactId> <version>2.4.3</version> <configuration> <projectId>GCLOUD_CONFIG</projectId> <version>GCLOUD_CONFIG</version> </configuration> </plugin>
Next, you need to create an app.yaml file.
Create a directory called
Create a file called app.yaml under
src/main/appengine. This file should have the following content.
You should change the java runtime version number (
java11) in the
yamlfile to match the value of the
<java.version>property in your pom.xml file.
You will also need to enable Cloud Build.
https://console.cloud.google.com/cloud-build/builds?project=PROJECT_NAME, replacing PROJECT_NAME with your project name found at Google Cloud Resource Manager.
Finally, you can build and deploy using a single command as follows:
mvn package appengine:deploy -Pproduction
When the deployment has finished, the application URL will be displayed in the logs.
If the deployment fails with an error similar to
ERROR: (gcloud.app.deploy) Error Response:  Access Not Configured., then ensure that your Google Cloud account has billing enabled.
After it is enabled, try to deploy again.
If you notice log messages similar to
Exceeded soft memory limit of 256 MB with X MB, this means your instance has ran out of RAM. You should consider upgrading to a larger App Engine instance that fits your needs.
|Be mindful of costs when upgrading. Larger instances will most likely incur more fees.|