How to fix Spring Boot auto restart and live reload in IntelliJ IDEA
- Details
- Written by Nam Ha Minh
- Last Updated on 29 February 2020   |   Print Email
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency>Then restart your Spring Boot application. In Eclipse or Spring Tool Suite, the automatic restart feature works immediately when you press Ctrl + S to save changes in the code.However, in IntelliJ IDEA, you have to press Ctrl + F9 (Build Project) to trigger hot restart of the application. This is quite inconvenient but a hot-swap restart is much faster than a cold, full restart. You also notice that the browser does not refresh automatically.To fix the problem and let IntelliJ IDEA triggers Spring Boot DevTools restarts the application really automatically, you need to do 2 extra steps.First, enable Build project automatically in the Settings dialog. Click menu File Settings > Build, Execution, Deployment > Compiler as shown below:Then open IntelliJ IDEA Registry. Press Shift + Ctrl + A and type registry:
compiler.automake.allow.when.app.running
And check to enable it:After done these two steps, you still have to deactivate IntelliJ IDEA window, e.g. switching to browser window (while testing) – for the Spring Boot application to restart. But it takes few seconds to happen – not as fast as in Eclipse/Spring Tool Suite.Now, the auto restart and live reload (auto refresh browser) will work but not as good as in Eclipse or Spring Tool Suite. Hope in the future release, IntelliJ IDEA will improve it.For visual steps, check out this video: To learn more about the automatic restart and live reload features of Spring Boot DevTools, check the following posts:- Spring Boot automatic restart using Spring Boot DevTools
- Spring Boot auto reload changes using LiveReload and DevTools
Other Spring Boot Tutorials:
- Spring Boot Hello World Example
- Spring Boot Form Handling Tutorial with Spring Form Tags and JSP
- Spring Boot Hello World RESTful Web Services Tutorial
- How to create a Spring Boot Web Application (Spring MVC with JSP/ThymeLeaf)
- Spring Boot - Spring Data JPA - MySQL Example
- Spring Boot CRUD Example with Spring MVC – Spring Data JPA – ThymeLeaf - Hibernate - MySQL
- How to use JDBC with Spring Boot
- Spring Boot CRUD Web Application with JDBC - Thymeleaf - Oracle
- Spring Boot RESTful CRUD API Examples with MySQL database
- How to package Spring Boot application to JAR and WAR
Comments