Backend Development 8 min read

One-Click Deployment of SpringBoot Projects Using IntelliJ IDEA and Docker

This tutorial demonstrates how to configure IntelliJ IDEA for remote one‑click deployment of a SpringBoot application with Docker, covering environment setup, SSH and Docker daemon configuration, Dockerfile creation, Maven build steps, firewall adjustments, and troubleshooting common deployment issues.

Architecture Digest
Architecture Digest
Architecture Digest
One-Click Deployment of SpringBoot Projects Using IntelliJ IDEA and Docker

This guide shows how to use IntelliJ IDEA 2024.2 together with Docker 26.1.3 to achieve one‑click remote deployment of a SpringBoot project, eliminating the repetitive steps of manual jar packaging and server upload.

1. Traditional deployment method

Typically you build a jar, upload it to the server, and start it with java -jar . Re‑deployments require repeating these steps and make log viewing inconvenient.

2. Prerequisites

Server with Docker installed and able to pull images.

Basic knowledge of writing a Dockerfile.

IntelliJ IDEA installed locally.

A SpringBoot project that can serve HTTP requests.

3. SSH configuration

Configure an SSH connection in IDEA settings (Host, Username, Password) and test the connection.

4. Connect to Docker daemon

Add a Docker configuration in IDEA, choose SSH as the connection method, select the previously created SSH profile, and apply the settings.

5. Create a simple SpringBoot application

Example controller:

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloWorldController {
@GetMapping("/")
public String index() {
return "<h1>Hello, world</h1>";
}
}

6. Write a Dockerfile

# Base image
FROM openjdk:17

# Copy the built jar into the image (place the jar next to the Dockerfile)
ADD target/one-click-deployment-0.0.1-SNAPSHOT.jar /one-click-deployment-0.0.1-SNAPSHOT.jar

# Container start command
ENTRYPOINT ["java", "-jar", "/one-click-deployment-0.0.1-SNAPSHOT.jar", "--spring.profiles.active=prod"]

# Expose the application port
EXPOSE 11020

7. Configure remote deployment in IDEA

Create a new Docker deployment configuration, select the Dockerfile, give the image and container custom names, and store the configuration as a project file.

Bind the container port (11020) to a host port.

Add pre‑deployment tasks: run Maven goals clean and package .

8. Deploy the project

Click the green run triangle; IDEA builds the image, pushes it via SSH, creates the container and starts the application. Logs appear in the IDEA console.

9. Open firewall port 11020

On Ubuntu: sudo ufw allow 11020 sudo ufw reload

On CentOS: sudo firewall-cmd --zone=public --add-port=11020/tcp --permanent sudo firewall-cmd --reload

10. Access the application

Open a browser and navigate to http:// :11020/ to see the "Hello, world" page.

11. Common issues

11.1 Cannot connect to the Docker daemon

Ensure the SSH user belongs to the docker group:

sudo usermod -aG docker $USER

Verify with getent group docker and restart IDEA.

11.2 No main manifest attribute in the jar

This occurs when the JAR lacks a defined main class. Add the main class configuration to pom.xml and ensure the SpringBoot Maven plugin is enabled.

After fixing the pom, rebuild the project and repeat the deployment steps.

DockerDevOpsSpringBootIntelliJ IDEAOne-Click Deployment
Architecture Digest
Written by

Architecture Digest

Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.