Getting a Spring Boot application running on Google Cloud Platform doesn't have to be complicated. Once you've got everything set up, deployment is literally one command: gcloud app deploy. Let me walk you through exactly how to get there.
By the end of this guide, you'll have:
Let's get started!
Before we dive in, make sure you have these installed and ready:
App Engine supports Java 17 and 21. I recommend JDK 21 for new projects.
# Check your Java version
java -version
If you need to install Java:
macOS (via Homebrew):
brew install openjdk@21
Windows (via Chocolatey):
choco install temurin21
Or download directly from Adoptium.
Linux (via SDKMAN!):
curl -s "https://get.sdkman.io" | bash
sdk install java 21-tem
Alternatively, use your distribution's package manager (e.g., apt install openjdk-21-jdk on Ubuntu/Debian).
This is how you'll deploy and manage your application. Install it from the official documentation.
macOS (via Homebrew):
brew install --cask google-cloud-sdk
Linux/WSL:
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
After installation, initialize the SDK:
gcloud init
This will walk you through signing in and selecting a default project.
If you don't have a project yet, create one:
gcloud projects create my-spring-app --name="My Spring App"
gcloud config set project my-spring-app
You can also create projects in the Cloud Console.
Enable App Engine for your project and select a region. Choose carefully—you can't change the region later!
gcloud app create --region=us-central
Popular regions include:
us-central - Iowa (good for US users)us-east1 - South Carolinaeurope-west - Belgiumasia-northeast1 - TokyoSee all available regions in the App Engine locations documentation.
App Engine requires billing to be enabled, even with the free tier. Visit the Billing page to set up a billing account.
Don't worry—App Engine has a generous free tier that covers most hobby projects.
Your application needs to be packaged as a JAR with an embedded server. If you're using Spring Boot with Maven or Gradle, you're already set.
Maven (pom.xml):
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Gradle (build.gradle):
plugins {
id 'org.springframework.boot' version '3.3.0'
}
bootJar {
enabled = true
}
Create an app.yaml file in src/main/appengine/ (this is the standard location App Engine expects):
runtime: java21
service: default
instance_class: F2
automatic_scaling:
min_instances: 0
max_instances: 10
target_cpu_utilization: 0.65
env_variables:
SPRING_PROFILES_ACTIVE: "gcp"
Let's break this down:
| Setting | What It Does |
|---|---|
runtime: java21 |
Specifies Java 21. Use java17 if needed. |
service: default |
The default service. You can have multiple services for microservices architectures. |
instance_class: F2 |
The instance size. F1 (256MB RAM) is smallest; F4 (1GB RAM) is largest for standard environment. |
min_instances: 0 |
Scales to zero when idle (saves money!). Set to 1+ to avoid cold starts. |
max_instances: 10 |
Maximum instances during traffic spikes. |
target_cpu_utilization: 0.65 |
Spawns new instances when CPU hits 65%. |
See all configuration options in the app.yaml reference.
Create an application-gcp.properties (or .yml) file for GCP-specific settings:
# Server configuration
server.port=8080
# Logging for App Engine
logging.level.root=INFO
# Disable Tomcat access logs (App Engine handles this)
server.tomcat.accesslog.enabled=false
Now for the fun part. From your project root, run:
# Build your application first
./mvnw clean package -DskipTests
# Deploy to App Engine
gcloud app deploy src/main/appengine/app.yaml
That's it! The gcloud app deploy command will:
The first deployment takes a few minutes. Subsequent deployments are faster.
Once deployed, open your app in a browser:
gcloud app browse
Or visit https://YOUR-PROJECT-ID.appspot.com directly.
Here are the commands you'll use most often:
# Deploy your application
gcloud app deploy src/main/appengine/app.yaml
# View logs in real-time
gcloud app logs tail -s default
# Open app in browser
gcloud app browse
# List all deployed versions
gcloud app versions list
# Check which services are running
gcloud app services list
# View current project
gcloud config get-value project
# Switch projects
gcloud config set project OTHER-PROJECT-ID
Every deployment creates a new version. You can manage traffic between versions:
# List versions
gcloud app versions list
# Send all traffic to a specific version
gcloud app services set-traffic default --splits=VERSION_ID=1
# Split traffic (useful for canary deployments)
gcloud app services set-traffic default --splits=v1=0.9,v2=0.1
App Engine can be very affordable if you configure it right:
min_instances: 0 — Scales to zero when not in use# Create a budget alert (also do this in Cloud Console)
gcloud billing budgets create \
--billing-account=YOUR-BILLING-ACCOUNT \
--display-name="App Engine Budget" \
--budget-amount=10USD
Visit the Pricing Calculator to estimate costs for your expected traffic.
Make sure you're authenticated and have the right project selected:
gcloud auth login
gcloud config set project YOUR-PROJECT-ID
Check the logs immediately after deployment:
gcloud app logs tail -s default
Common issues:
app.yamlIf your app takes too long to respond after periods of inactivity, set min_instances: 1 in your app.yaml to keep at least one instance warm.
Once you've got basic deployment working, consider exploring:
Deploying Spring Boot to Google Cloud Platform really is as simple as one command once you've done the initial setup. The combination of App Engine's automatic scaling, the generous free tier, and the simplicity of gcloud app deploy makes it a fantastic choice for hobby projects and production applications alike.
The hardest part is the first deployment—getting all the prerequisites in place. After that, shipping updates is effortless. I hope this guide helps you get there faster!
–Jeremy
Thanks for reading! I'd love to hear your thoughts.
Have questions, feedback, or just want to say hello? I always enjoy connecting with readers.
Get in TouchPublished on July 16, 2025 in tech