How to Enable Hot Reload and Remote Debugging with Spring Boot DevTools

This guide explains how to integrate Spring Boot DevTools into a Spring Boot project to achieve automatic hot deployment and remote debugging, covering Maven dependency setup, IDE configuration, Docker packaging, and step‑by‑step code examples.

Su San Talks Tech
Su San Talks Tech
Su San Talks Tech
How to Enable Hot Reload and Remote Debugging with Spring Boot DevTools

Overview

Spring Boot DevTools provides automatic hot restart and optional remote debugging, reducing the need to rebuild and redeploy JAR files after each code change.

How DevTools works

It uses two class loaders: a base class loader for immutable classes (third‑party libraries) and a restart class loader for application classes. On restart only the restart class loader is refreshed, making restarts faster than a full cold start.

Hot reload setup

Add the optional devtools dependency to pom.xml:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>

Create a simple controller that returns a message:

@Tag(name = "TestController", description = "SpringBoot DevTools test")
@Controller
@RequestMapping("/test")
public class TestController {

    @Operation(summary = "Test modify")
    @RequestMapping(value = "/first", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult first() {
        String message = "返回消息";
        return CommonResult.success(null, message);
    }
}

Run the application. With DevTools on the classpath, any change to the controller source triggers an automatic restart. Modifying the message field and saving the file updates the response without rebuilding the JAR.

{
  "code": 200,
  "message": "返回消息(已修改)",
  "data": null
}

Enable automatic compilation in IntelliJ (Settings → Build, Execution, Deployment → Compiler → “Build project automatically”) or trigger a manual build when the IDE loses focus so DevTools can detect changes.

IDE auto‑build setting
IDE auto‑build setting

Remote debugging

To enable remote debugging, include DevTools in the packaged artifact and configure the Spring Boot Maven plugin not to exclude it:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <excludeDevtools>false</excludeDevtools>
    </configuration>
</plugin>

Add a secret to application.yml:

spring:
  devtools:
    remote:
      secret: macro666

Build a Docker image and run it, exposing the application port:

docker run -p 8088:8088 --name spring-devtools -d spring-examples/spring-devtools:1.0-SNAPSHOT

Create a “Remote Spring Application” run configuration in IntelliJ. Set the main class to org.springframework.boot.devtools.RemoteSpringApplication and the program argument to the container URL, e.g. http://192.168.3.101:8088.

Remote debugging configuration
Remote debugging configuration

When the configuration starts, the console prints messages similar to:

2025-07-22T10:22:13.452+08:00  INFO 34364 --- [spring-devtools] o.s.b.devtools.RemoteSpringApplication : Starting RemoteSpringApplication v3.4.2 using Java 17.0.9 with PID 34364
2025-07-22T10:22:13.584+08:00  INFO 34364 --- [spring-devtools] o.s.b.devtools.RemoteSpringApplication : Started RemoteSpringApplication in 0.352 seconds (process running for 0.739)

After modifying the controller’s message field and rebuilding (or triggering a manual build), the remote service restarts automatically and serves the updated response:

{
  "code": 200,
  "message": "返回消息(远程调试)",
  "data": null
}

Key points

DevTools speeds up development by restarting only the application class loader.

Hot reload works out of the box after adding the optional dependency; ensure the IDE compiles automatically.

Remote debugging requires the devtools JAR in the artifact, excludeDevtools set to false, and a secret defined in application.yml.

Docker can be used to run the application; IntelliJ’s RemoteSpringApplication connects to the container using the secret.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockermavenSpring Boothot-reloadDevToolsremote debugging
Su San Talks Tech
Written by

Su San Talks Tech

Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.

0 followers
Reader feedback

How this landed with the community

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.