Skip to content
COL0

How to deploy a Java (Spring Boot) app on a server

Your Spring Boot application runs perfectly from the IDE. To publish it you need a JAR, the right Java version, a service that does not shut down and a proxy with HTTPS.

Written by Victor Barrera

What you need before starting

  • A Linux server with SSH and a JDK or JRE matching the version you compile with.
  • A database reachable from the server and a domain.

The steps, in short

  1. Package the project: ./mvnw clean package (or ./gradlew bootJar). You get an executable JAR in target/ or build/libs/.
  2. Separate the configuration: use a prod profile and environment variables for credentials; do not leave them in application.properties inside the JAR.
  3. Upload the JAR to the server and test it with java -jar app.jar.
  4. Create a systemd service with automatic restart and an -Xmx that fits the server.
  5. Put Nginx in front as a proxy to the app’s port (8080 by default) and enable HTTPS with Let’s Encrypt.
  6. Check the health endpoints (Spring Boot Actuator) to monitor that the app is alive.

Common mistakes

  • Compiling with a newer Java version than the one installed on the server.
  • Leaving the app port open to the public instead of only Nginx.
  • Leaving the H2 console or Actuator endpoints exposed without protection.
  • Running with the development configuration (ddl-auto=update, debug logs) in production.

How we help

In the free session we review your project and define the server, memory and database. Then we publish it with HTTPS, automatic deploys and monitoring.

Frequently asked questions

How much memory does my Spring Boot app need?

As a starting point, a server with 1 to 2 GB of RAM is enough for a small application. It is a good idea to cap the JVM memory with -Xmx so it does not compete with the rest of the system.

Should I use an external Tomcat or the executable JAR?

For new projects, the executable JAR with embedded Tomcat is simplest. A WAR on an external Tomcat only makes sense if your organization already works that way.

Ready to publish your project?

Book your free 30-minute session and leave with a clear plan.

Book your free session