Spring Boot

Spring Boot

Short guide to publish a Spring Boot app on Devployer.

Before you start

  • GitHub repository with your Spring Boot project
  • Build tool detected by Nixpacks:
    • Maven: pom.xml at the root
    • Gradle: gradlew (wrapper) at the root
  • Compatible JDK (Nixpacks defaults to 17; also supports 8 and 11)

Step by step

1. Prepare the repository

Make sure the project builds locally:

# Maven
./mvnw -DskipTests package
# or: mvn -DskipTests package

# Gradle
./gradlew build -x test

A nixpacks.toml is not required for the standard case: Nixpacks detects Java and runs the Spring Boot JAR.

2. (Optional) Pin the JDK version

If you need another Java version, set this environment variable in Devployer:

NIXPACKS_JDK_VERSION=8

For Gradle, you can also pin:

NIXPACKS_GRADLE_VERSION=8

3. Create the application in Devployer

  1. Open Devployer and choose Deploy from GitHub
  2. Select the repository and branch
  3. Choose the Spring Boot framework
  4. Create the application (you can enable instant deploy)

4. Configure environment variables

VariableNotes
NIXPACKS_JDK_VERSIONOptional: 17 (default), 8, 11
JAVA_OPTSOptional: JVM memory, e.g. -Xmx512m
SPRING_PROFILES_ACTIVEOptional: e.g. prod

Managed database

When you attach a database from Devployer, these are injected automatically:

PostgreSQL / MySQL / MariaDB

Variable
SPRING_DATASOURCE_URL
SPRING_DATASOURCE_USERNAME
SPRING_DATASOURCE_PASSWORD
DATABASE_URL

MongoDB

Variable
SPRING_DATA_MONGODB_URI
SPRING_DATA_MONGODB_DATABASE
SPRING_DATA_MONGODB_USERNAME
SPRING_DATA_MONGODB_PASSWORD
SPRING_DATA_MONGODB_AUTHENTICATION_DATABASE

After attaching the database, the app restarts so the variables take effect.

5. Deploy and verify

  1. Wait for the build to finish
  2. Open the public URL
  3. If it fails, check the deployment logs in Devployer

What Nixpacks does by default

Maven

  • Build: mvn -DskipTests clean dependency:list install
  • Start: java $JAVA_OPTS -jar target/*jar

Gradle

  • Build: ./gradlew clean build -x check -x test
  • Start: java $JAVA_OPTS -jar $(ls -1 build/libs/*jar | grep -v plain)

(Optional) Custom nixpacks.toml

Only if you need to override install/build/start. Minimal example:

[phases.build]
cmds = ["./mvnw -DskipTests package"]

[start]
cmd = "java $JAVA_OPTS -jar target/*.jar"

Commit, push, then Redeploy.

Quick checklist

  • pom.xml or gradlew at the repo root
  • Project builds locally without blocking tests
  • Spring Boot framework selected in Devployer
  • Correct JDK (NIXPACKS_JDK_VERSION if not 17)
  • Database env vars injected if using a managed database
  • Redeploy after changing dependencies or nixpacks.toml