The Spring Boot DevTools works very well in Eclipse and Spring Tool Suite, for automatic restart the application and auto refresh the browser whenever we make changes to code of a Spring Boot project.

However, in IntelliJ IDEA, it behaves slightly different and you need to do few extra steps to get it works properly.

Basically, to use Spring Boot Developer Tools, add the following dependency to your project’s Maven build file:

<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:

build project automatically intellij idea

Then open IntelliJ IDEA Registry. Press Shift + Ctrl + A and type registry:



IntelliJ IDEA open Registry

Then in the Registry dialog, search for this key:

compiler.automake.allow.when.app.running

And check to enable it:

intellj idea registry automake

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:

 

Other Spring Boot Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Add comment

   


Comments 

#3Bogdi2021-01-19 08:34
Great work. Very wonderful explained.
Quote
#2Waseem Hawaldar2021-01-08 07:50
Very helpful content. Thanks for sharing.
Quote
#1Trương Huỳnh Hòa2020-03-11 09:34
Thank ad for your sharing
Quote