This sample shows how to run a Spring Boot application on Google Cloud Platform. It uses the Google App Engine flexible environment.
This sample assumes you have Java 8 installed.
These samples use the Apache Maven build system. Before getting started, be sure to download and install it. When you use Maven as described here, it will automatically download the needed client libraries.
If you haven't already created a project, create one now. Projects enable you to manage all Google Cloud Platform resources for your app, including deployment, access control, billing, and services.
- Open the Cloud Platform Console.
- In the drop-down menu at the top, select Create a project.
- Give your project a name.
- Make a note of the project ID, which might be different from the project name. The project ID is used in commands and in configurations.
If you haven't already enabled billing for your project, enable billing now. Enabling billing allows the application to consume billable resources such as running instances and storing data.
If you haven't already installed the Google Cloud SDK, install and initialize the Google Cloud SDK now. The SDK contains tools and libraries that enable you to create and manage resources on Google Cloud Platform.
gcloud components update app-engine-java
gcloud components update
The app.yaml
descriptor is used to describe URL
dispatch and resource requirements. This example sets
manual_scaling
to 1 to minimize possible costs.
These settings should be revisited for production use.
- Set the correct Cloud SDK project via
gcloud config set project YOUR_PROJECT
to the ID of your application. - Run
mvn spring-boot:run
- Visit http://localhost:8080
mvn appengine:deploy
- Visit
http://YOUR_PROJECT.appspot.com
.
Note that deployment to the App Engine flexible environment requires the new
com.google.cloud.tools:appengine-maven-plugin
plugin.
Java is a registered trademark of Oracle Corporation and/or its affiliates.