How to Enable Hot Reload and Remote Debugging in Spring Boot with DevTools
This guide shows how to integrate Spring Boot DevTools for automatic hot deployment, configure remote debugging via Docker, and streamline development with IDE auto‑build settings, providing step‑by‑step code examples and configuration snippets.
Introduction
spring-boot-devtoolsis an official Spring Boot tool that enables hot deployment and remote debugging. It uses two class loaders: a base loader for unchanged classes and a restart loader for application classes, making restarts faster.
Hot Deployment
We integrate devtools into a Spring Boot project to demonstrate hot deployment.
Add the devtools dependency to pom.xml (optional true).
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>Add a test controller that returns a message.
@Tag(name = "TestController", description = "SpringBoot Dev Tools测试")
@Controller
@RequestMapping("/test")
public class TestController {
@Operation(summary = "测试修改")
@RequestMapping(value = "/first", method = RequestMethod.GET)
@ResponseBody
public CommonResult first() {
String message = "返回消息";
return CommonResult.success(null, message);
}
}Run the application; Swagger UI can be used to call the test endpoint.
{
"code": 200,
"message": "返回消息",
"data": null
}Enable automatic build in the IDE when it loses focus so changes trigger restart.
Modify the message variable in the controller; after focus loss the new message is applied automatically.
{
"code": 200,
"message": "返回消息(已修改)",
"data": null
}Remote Debugging
DevTools also supports remote debugging. The application is packaged into a Docker container and run.
Add configuration to the Spring Boot Maven plugin to avoid excluding devtools.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludeDevtools>false</excludeDevtools>
</configuration>
</plugin>Set remote access password in application.yml.
spring:
devtools:
remote:
secret: macro666Build Docker image and run:
docker run -p 8088:8088 --name spring-devtools -d spring-examples/spring-devtools:1.0-SNAPSHOTCreate a Remote Spring Application run configuration in the IDE, using org.springframework.boot.devtools.RemoteSpringApplication and the container URL.
Console output shows successful remote connection.
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.454+08:00 INFO 34364 --- [spring-devtools] o.s.b.devtools.RemoteSpringApplication : No active profile, falling back to 1 default profile: "default"
2025-07-22T10:22:13.573+08:00 INFO 34364 --- [spring-devtools] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
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)Modify the controller's message variable; after manual build the remote service restarts and returns the updated message.
{
"code": 200,
"message": "返回消息(远程调试)",
"data": null
}Conclusion
Spring Boot’s devtools provides fast hot reload and remote debugging, making development more efficient.
Source code: https://github.com/macrozheng/spring-examples/tree/master/spring-devtools
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
