Deploy Spring Boot
Deploy a Spring Boot application on Out Plane, with a managed database.
This guide deploys a Spring Boot application and connects it to a managed PostgreSQL database. For the shared deploy flow, see Deploy from GitHub.
Prepare Your App
Bind the Port
Spring Boot already listens on 0.0.0.0. Drive the port from the environment, with a
default for local development:
server.port=${PORT:8080}Do not set server.address to localhost, or the app becomes unreachable. Expose the same
port in Networking.
Deploy
Create an application from your repository. Spring Boot has first class Buildpacks
support, so a build with no Dockerfile works out of the box. For a Dockerfile, the JAR
runs with java -jar. The start command runs as a direct exec, so a wildcard path needs a
shell:
sh -c "java -jar target/*.jar"A fixed JAR name copied in your Dockerfile avoids the wildcard entirely.
Connect a Database
Create a managed PostgreSQL database. Spring's relaxed binding lets you set datasource properties from environment variables:
SPRING_DATASOURCE_URL=jdbc:postgresql://host:5432/dbname?sslmode=require
SPRING_DATASOURCE_USERNAME=...
SPRING_DATASOURCE_PASSWORD=...Connections require SSL, so keep ?sslmode=require in the URL. Copy the JDBC formatted
string from the database's Connection panel.
Run Migrations
Use Flyway or Liquibase, which run automatically on startup and take a lock that is safe across multiple instances. This is the cleanest fit for Out Plane, which has no separate pre deploy hook.
Environment Variables
| Variable | Notes |
|---|---|
SPRING_PROFILES_ACTIVE | prod, to load application-prod.properties. |
SPRING_DATASOURCE_URL | The JDBC connection string. |
JAVA_OPTS | Optional heap flags, if your start command applies them. |