---
title: "How to deploy a Java Spring Boot app on Rock8Cloud"
description: "Deploy your Spring Boot app to Rock8Cloud - a runnable jar in its own container. Connect your GitHub repo, hit deploy, live in about two minutes, provisioned PostgreSQL one click away."
tech: "Java"
icon: java
category: backend
pubDate: 2026-06-03
updatedDate: 2026-08-28
image: /how-to/og/java.png
imageAlt: "How to deploy Java on Rock8Cloud"
headerImage: true
exampleRepo: https://github.com/rock8-cloud/template-java
port: 8080
ctaTitle: "Ship your Java app."
ctaTitleHighlight: "Today."
ctaSubtitle: "Connect the repo, hit deploy, share the URL. Everything after that is just git push."
ctaIcons: [java, postgresql, docker]
order: 50
steps:
  - name: "Select GitHub repository deployment"
    text: "In your Rock8Cloud project, choose GitHub repository deployment and connect your repo."
  - name: "Hit Deploy"
    text: "Rock8Cloud builds the image and serves your app at a live public URL. The container port is inferred from your Dockerfile's EXPOSE."
  - name: "Provision a database"
    text: "Provision a PostgreSQL in the project and link it - the connection variables become accessible and your app redeploys."
faq:
  - q: "Do I need a Dockerfile to deploy Java?"
    a: "Yes - copy the example from this guide. If it sets EXPOSE, Rock8Cloud infers the container port automatically, so there is nothing else to configure."
  - q: "Is there a faster way to try it?"
    a: "Yes - the open-source Java template (Spring Boot REST API, Maven, JDK 21) clones to your GitHub and goes live wired to a provisioned PostgreSQL in one click. You can assign your own domain later."
  - q: "Maven or Gradle?"
    a: "This guide and the template use Maven. For Gradle, see the Kotlin guide - the same build approach applies to Gradle-based Java projects."
  - q: "Which JDK does the example use?"
    a: "The example Dockerfile pins JDK 21 (eclipse-temurin) - bump the build and runtime images to match your project's toolchain."
  - q: "How do I connect a database to my Java app?"
    a: "Provision a PostgreSQL in your project and link it to the service. Map it to DATABASE_URL or spring.datasource.* variables - they become accessible on the next deploy."
---

A Spring Boot app packages into a single runnable jar and ships in its own container. Connect your GitHub repo, hit deploy, and you get a live URL in about two minutes - with a provisioned PostgreSQL one click away.

## Deploy your app

One step: select **GitHub repository** deployment, connect your repo, and hit **Deploy**. Rock8Cloud builds the container image and serves your app at a live URL, with build and runtime logs in your browser.

No Dockerfile in the repo? Copy the example below.



> **Pro tip:** Set `EXPOSE` in your Dockerfile and Rock8Cloud infers the container port automatically - nothing else to configure.



**Example Dockerfile**



```dockerfile
# Build
FROM maven:3.9-eclipse-temurin-21 AS build
WORKDIR /app
COPY pom.xml .
RUN mvn -q dependency:go-offline
COPY src ./src
RUN mvn -q clean package -DskipTests

# Run
FROM eclipse-temurin:21-jre-alpine
COPY --from=build /app/target/*.jar /app.jar
EXPOSE 8080
CMD ["java", "-jar", "/app.jar"]
```

`EXPOSE 8080` is what Rock8Cloud reads to route traffic to your container - Spring Boot's default port, no manual setting needed.

## Don't have an app?

One-click start from our open-source template - a [Spring Boot](https://spring.io/projects/spring-boot) REST API built with Maven on JDK 21, with PostgreSQL wired in. It's cloned to your GitHub, connected to a provisioned Postgres, and put live on our domain. Or just browse it on GitHub and borrow what you need.



> **Pro tip:** You can assign your own domain to the app later.





[Java + Postgres example](https://github.com/rock8-cloud/template-java)

[1-click clone & deploy](https://app.rock8.cloud/new-deployment?blueprint=java-maven-postgres&utm_source=howto&utm_medium=landing&utm_campaign=howto&utm_content=java)



Or ask an agent instead of clicking. With Rock8Cloud [connected over MCP](/how-to/connect-claude), `deploy_blueprint` with the `java-maven-postgres` slug forks the same template into your GitHub account, creates the project with its services, and starts the first build.



## Add a database

Rock8Cloud provisions databases inside your project - no external vendor, no separate bill. Secure credentials and networking are handled for you. Two engines are available:

- **PostgreSQL** - relational database (versions 14–17), 1–100 GB storage, optional high-availability replica.
- **Dragonfly** - a Redis-compatible in-memory store for caching, sessions, and queues. Drop-in for any Redis client.

### Create it, then set environment variables

1. In your project, choose **Add Service → Database**, then pick the engine, version, and storage. Rock8Cloud provisions it with secure, auto-generated credentials.
2. Open your Java app and switch to the **Env vars** tab - home to all of your app's environment variables. Set any custom keys you need. Linked database values live right alongside them.
3. Add the database's connection variables under the names your framework expects (for example `DATABASE_URL`). Save, and your Java app automatically redeploys with the connection wired in.

[Link environment variables in one click](https://minio.11333311.xyz/vibeham-docs/env_configuration.mp4)

The connection values are accessible to your app as plain environment variables - read them the standard way for your stack. Databases are network-isolated to your project: reachable only by your own services, never exposed publicly. Available databases & storage: [PostgreSQL](/how-to/provision-postgresql) · [Dragonfly (Redis)](/how-to/provision-dragonfly) · [S3 object storage](/how-to/provision-s3).



## What you get

- A **live URL** on our domain - share it the moment the first build lands.
- **Deploy on push** - every push to your configured default branch rebuilds and ships automatically.
- A **preview URL per pull request** - review real builds, not screenshots.
- **Instant rollback** - one click back to any known-good build.

## Add a frontend?

Serving a SPA in front of your API? Deploy it as its own service - see the [Vue guide](/how-to/deploy-vue) - and point it at your API's URL with a build-time variable. Need caching or file storage too? [Dragonfly](/how-to/provision-dragonfly) and [S3](/how-to/provision-s3) are one click each.
