--- title: "Deploy a Spring Boot App" description: "Deploy a Spring Boot application on Miget with git push, the right port config, and a PostgreSQL database." --- Miget builds your Spring Boot app straight from source and runs the resulting JAR - no Dockerfile or CLI required. This guide walks you from a fresh app to a live deployment, then connects a PostgreSQL database. ## Prerequisites Before you start, make sure you have: - A [Miget account](https://app.miget.com) - Git installed and your project under version control - A Spring Boot app with a `pom.xml` (Maven) or `build.gradle` (Gradle) ## How the build works Miget's [buildpacks](/overview/buildpacks) auto-detect Java from your `pom.xml` or `build.gradle`, build your project, and run the produced JAR using the `Main-Class` declared in its manifest. You do not need to write a build script or container image. Every app on Miget must listen on **`0.0.0.0:5000`**. Miget sets an immutable `PORT=5000`, and public ingress only reaches port 5000. Spring Boot defaults to port **8080** and does **not** read `PORT` on its own, so you must configure it - see the port step below. See [Ports](/networking/ports) for details. ## Configure the port Point Spring Boot at the injected `PORT` so it binds to 5000 in production. Add this to `src/main/resources/application.properties`: ```properties server.port=${PORT:8080} ``` This reads Miget's `PORT` (5000) when deployed and falls back to 8080 for local development. Prefer environment variables? Set `SERVER_PORT=5000` on the app instead - Spring Boot maps it to `server.port` automatically. Either approach works; pick one. Commit the change before deploying: ```bash git add src/main/resources/application.properties git commit -m "Bind to Miget PORT" ``` ## Deploy with git push Go to [app.miget.com](https://app.miget.com), click **New → Application**, give it a name, pick the resource it should run in, then click **Next**. Select **Auto detection (Miget Buildpacks)**, choose an instance size, then click **Next**. Miget will detect Java from your `pom.xml` or `build.gradle`. Choose **git push**, click **Create**, and copy the deploy token shown. You'll need it to authenticate the push. Add Miget as a git remote, then push: ```bash git remote add miget https://git..miget.io// git push miget ``` Replace ``, ``, and `` with the values from the create screen. Miget builds your app and deploys the JAR. See [Git push to builder](/deployments/git-push-to-builder) for the full flow. This guide uses **git push**, but it's one of several ways to deploy. You can also connect a [GitHub repository](/deployments/github-integration) for auto-deploys and pull request previews, deploy from a public Git repository, or push a prebuilt [container image](/deployments/container-registry). See [all deployment methods](/deployments/how-it-works). ## Connect a database Add a **PostgreSQL** addon to your app from the dashboard. Miget provisions it and auto-injects a `DATABASE_URL` environment variable in this form: ``` postgres://user:password@host:port/dbname ``` Spring Boot and the JDBC driver do **not** parse the `postgres://` scheme directly. You must give Spring a proper JDBC URL plus separate credentials - do not point `spring.datasource.url` at the raw `DATABASE_URL`. The cleanest approach is to set three environment variables on your app (from the values inside `DATABASE_URL`) and reference them in `application.properties`: ```properties spring.datasource.url=${SPRING_DATASOURCE_URL} spring.datasource.username=${SPRING_DATASOURCE_USERNAME} spring.datasource.password=${SPRING_DATASOURCE_PASSWORD} ``` Then set these on the app, converting the injected `DATABASE_URL` into a JDBC URL: - `SPRING_DATASOURCE_URL` → `jdbc:postgresql://host:port/dbname` - `SPRING_DATASOURCE_USERNAME` → the `user` from `DATABASE_URL` - `SPRING_DATASOURCE_PASSWORD` → the `password` from `DATABASE_URL` Note the JDBC URL uses the `jdbc:postgresql://` scheme with the host, port, and database name - it drops the credentials, which travel in the username/password properties. Manage credentials as [secrets](/deployments/using-secrets) so they're never committed to your repo. See [PostgreSQL](/databases/postgresql) for connection details and addon management. ## Next steps Provision, connect, and manage Postgres addons. Point your own domain at your Spring Boot app. Inject credentials and config without committing them. Understand how Miget shares CPU across your apps.