Deploying a Spring Boot App to Production (Beginner Guide)
Get your Spring Boot app online: build a production jar, choose a host (PaaS vs VPS vs cloud), set prod config and secrets, add HTTPS and a domain, then monitor it.
You've built an app, connected a database, secured it, and containerised it. Now for the moment that makes it all real: putting it on the internet so anyone, anywhere, can use it. Deployment used to be intimidating, but modern platforms have made it genuinely approachable. This lesson walks you through the concepts and your realistic options for getting a Spring Boot app live.
What "deploying" actually means
Deploying means running your app on a server that's always on and reachable over the internet, instead of just on your laptop. Users hit a public web address, and your app responds. To get there, you need a few things in place: a built app, a place to run it, a database it can reach, and its configuration/secrets supplied by the environment.
Step 1: Build a production-ready artifact
First, package your app into a runnable jar (or a Docker image from the last lesson):
./mvnw clean package -DskipTests
# produces target/myapp.jar — a single runnable file
Because Spring Boot bundles its own server, this one jar is your whole app. On any machine with Java you can run java -jar myapp.jar and it's live. That simplicity is a big part of why Spring Boot is so pleasant to deploy.
Step 2: Choose where to run it
You have a spectrum of options, from easiest to most hands-on:
| Option | Good for |
|---|---|
| PaaS (Render, Railway, Heroku) | beginners — push code, they handle servers |
| VPS (DigitalOcean, Linode, EC2) | full control, cheap, more manual setup |
| Cloud + containers (AWS, GCP, Azure) | scaling to large production systems |
Step 3: Configure the production environment
This is where the earlier lessons pay off. On your host you'll set:
- The active profile:
SPRING_PROFILES_ACTIVE=prod(from the config lesson). - Secrets as environment variables:
DB_USERNAME,DB_PASSWORD, JWT secret, email keys — never in your code. - A production database: most PaaS providers offer a managed PostgreSQL you point your app at via
DB_*variables.
Because you externalised config and secrets from day one, "going to production" is mostly just supplying the right environment variables — no code changes. That's the reward for doing configuration properly.
Step 4: HTTPS, domain, and going live
For a real site you'll want a custom domain (e.g. myapp.com) and HTTPS (the padlock — essential for security and trust). The good news: most PaaS platforms provide free HTTPS automatically and make attaching a domain a few clicks. Point your domain's DNS at the platform, and you're live and secure.
Step 5: After deploying — keep an eye on it
Once live, use what you built in the Actuator & logging lesson: the /actuator/health endpoint tells uptime monitors your app is alive, and your logs are your first stop when something misbehaves. Deployment isn't the finish line — it's the start of running a real service.
Honestly, my first deployment was equal parts terrifying and exhilarating — watching my app respond at a real public URL for the first time is a feeling I still remember. This website runs on exactly this kind of setup: a containerised Spring Boot app on a cloud platform, with secrets in environment variables, a managed PostgreSQL database, and HTTPS. My biggest piece of advice: for your first deploy, pick the easiest PaaS you can and just get something live end to end. Don't get lost optimising infrastructure before you've shipped once. That first live URL — something the whole world can visit — is a milestone worth chasing. Go make it happen.
Key takeaways
- Deploying = running your app on an always-on, internet-reachable server; Spring Boot's single jar makes this simple.
- Beginners should start with a PaaS (Render/Railway/Heroku) — push code, get a live URL, no server admin.
- Supply the prod profile, secrets via env variables, and a managed database — no code changes needed.
- Add a custom domain + HTTPS (usually free/automatic on PaaS), then monitor via Actuator health and logs.
← Previous: Spring Lesson 16 — Dockerizing Your App
Next: Spring Lesson 18 — Design Patterns & Best Practices →
↑ Back to the Spring Boot roadmap