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.xmlat the root - Gradle:
gradlew(wrapper) at the root
- Maven:
- 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
- Open Devployer and choose Deploy from GitHub
- Select the repository and branch
- Choose the Spring Boot framework
- Create the application (you can enable instant deploy)
4. Configure environment variables
| Variable | Notes |
|---|---|
NIXPACKS_JDK_VERSION | Optional: 17 (default), 8, 11 |
JAVA_OPTS | Optional: JVM memory, e.g. -Xmx512m |
SPRING_PROFILES_ACTIVE | Optional: 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
- Wait for the build to finish
- Open the public URL
- 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.xmlorgradlewat the repo root - Project builds locally without blocking tests
- Spring Boot framework selected in Devployer
- Correct JDK (
NIXPACKS_JDK_VERSIONif not 17) - Database env vars injected if using a managed database
- Redeploy after changing dependencies or
nixpacks.toml