# How to deploy a Spring Boot app.

URL: https://antideploy.com/blog/how-to-deploy-a-spring-boot-app

Spring Boot deploys with one sentence. Antideploy builds the jar and runs it, and you build the database URL from the PG variables.

## At a glance

- **Maven or Gradle**: Detected from pom.xml or build.gradle
- **An executable jar**: The build sets the entrypoint
- **Port 8080**: Read PORT to be safe
- **A JDBC URL**: Built from the PG variables

Published 7 October 2026. Facts checked 7 October 2026. 3 min read.

## The short answer

To deploy a Spring Boot app, give your coding agent the sentence below. Antideploy finds `pom.xml` or `build.gradle`, builds your project into an executable jar, and runs it. The port is 8080, which is also Spring's default. For Postgres, Antideploy sets `DATABASE_URL` and the `PG*` variables, and Spring needs a JDBC URL, so you build one from the `PG*` variables. A Java app has 2 GB of memory.

> **Say this to your coding agent**
>
> Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.

## What Antideploy detects

- **Java.** Detected from `pom.xml` for Maven, or `build.gradle` or `build.gradle.kts` for Gradle.
- **The start command.** Antideploy does not add one. The build produces an executable jar and sets the entrypoint from it. Your project needs the Spring Boot plugin so the jar is executable.
- **The port.** For Java projects, Antideploy sends traffic to port 8080 and sets `PORT` to match.
- **The database.** Antideploy creates Postgres and sets `DATABASE_URL` and the `PG*` variables.

## The settings your app needs

Spring does not read `DATABASE_URL`, because it is not a JDBC URL. Build the JDBC URL from the `PG*` variables that Antideploy sets.

**application.properties**

```
server.port=${PORT:8080}

spring.datasource.url=jdbc:postgresql://${PGHOST}:${PGPORT}/${PGDATABASE}?sslmode=require
spring.datasource.username=${PGUSER}
spring.datasource.password=${PGPASSWORD}
```

Add the PostgreSQL JDBC driver to your `pom.xml` or `build.gradle`. If you use Flyway or Liquibase, they run when the app starts. Antideploy's own migration step is for Prisma, Drizzle, Django and Alembic projects.

## Memory and startup

A Spring Boot app is a Java process. Java apps run on 1 dedicated vCPU with 2 GB of memory in total, because a JVM starts slowly on a shared CPU. Other apps get 1 shared vCPU and 1 GB. Keep heap settings below 2 GB, and avoid loading large data at startup. A Spring Boot app also takes longer to start than a small Node or Python app, so the first request after the app sleeps can take longer too.

## Step by step

### 1. Check the build on your machine

`mvn package` or `./gradlew build` should produce a jar that runs with `java -jar`.

### 2. Paste the sentence and approve one link

Your agent creates the app and the database, and writes the connection details into your `.env` without printing them.

### 3. Deploy and open the link

Antideploy builds the project, starts the jar, and checks that it answers. If the app never listens on its port, the deploy fails and shows what the app printed before it exited.

## Common problems

- **The app never starts listening.** The jar crashed on startup, often a database setting. The deploy shows the last lines the app printed. See [never started listening](https://antideploy.com/blog/your-app-built-successfully-but-never-started-listening-on-its-port).
- **The build fails to compile.** The deploy names the Java file and the error, or the Maven plugin that failed.
- **A connection refused.** The datasource URL still points at `localhost`. Use the `PG*` variables.

## Here's where it stops.

A platform that only tells you what it is good at is one you find the edges of in production. These are the ones to know before your first deploy.

### Apps sleep when idle

On every plan, an app nobody is using goes to sleep and the next visit wakes it. The first request took 2.9 to 13.9 seconds in our measurements, depending on the stack. There are no always-on workers, so use a cron job or a webhook for background work.

### One instance, no previews

Each app is one instance with 1 shared vCPU and 1 GB of memory, and a Java app gets 1 dedicated vCPU and 2 GB. There are no preview deployments and no per-branch URLs.

### The disk forgets

Anything written to local disk is gone on the next deploy. Apps that speak S3 get a bucket instead.

## Spring Boot questions, answered.

Anything else? Write to us and a person answers.

[support@antideploy.com](mailto:support@antideploy.com)

### Do I need a Dockerfile for Spring Boot?

No. If there is no Dockerfile, Antideploy builds the project with Maven or Gradle. If you add one at the root, it is used.

### Which Java version is used?

The builder's. If your project needs a specific version, a Dockerfile gives you control.

### Why is the first request slow?

Apps sleep when idle and the first request after sleeping waits for the app to start. Java apps start more slowly than small Node or Python apps.

### What does it cost?

A Spring Boot app counts as one live app. The Free plan includes 1 live app with a server and 1 Postgres database.

## More guides, and the platform.

Each platform page covers one part of Antideploy: what it does, where it stops and the questions people ask. [See the whole platform](https://antideploy.com/platform), or [all the guides](https://antideploy.com/blog).

- [How to deploy a Go app](https://antideploy.com/blog/how-to-deploy-a-go-app): go.mod, the built binary, the PORT variable, Postgres and the go.sum fix.
- [How to add a Postgres database to your app](https://antideploy.com/blog/how-to-add-a-postgres-database-to-your-app): Ask your agent. A Postgres 17 database is created beside your app and DATABASE_URL is set.
- [Your app built successfully but never started listening on its port](https://antideploy.com/blog/your-app-built-successfully-but-never-started-listening-on-its-port): The app built but never answered on its port. Read PORT, listen on 0.0.0.0 and check the logs.

- [Hosting](https://antideploy.com/platform/hosting)
- [Database](https://antideploy.com/platform/database)
- [Environment variables](https://antideploy.com/platform/environment-variables)
- [Deployments](https://antideploy.com/platform/deployments)

Facts on this page were checked against the live platform on 7 October 2026.

## Deploy something. Start with one sentence.

Paste one sentence into your coding agent, click Approve once, and get a live link. No card, no trial clock.

To set this up, give your coding agent this sentence:

```text
Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.
```
