How to configure IDEA for Spring Boot DevTools

Answered

I'm developing a Spring Boot application in Kotlin with IDEA.

I leave the build to IDEA (not delegating to Gradle), I have installed the `spring-boot-devtools` module, and I'm launching the application using a Run Configuration of type Kotlin, pointing to my ApplicationKt class.

This works, but whenever I trigger a rebuild, IDEA puts the compiled classes into the output directory incrementally, as they are done (and probably clears the output directory beforehand.) As soon as the first change hits the output directory, the running application detects it and triggers a hot-restart. But most of the times the restart completes before IDEA has finished building the project, resulting in a broken run.

Spring Boot has a `spring.devtools.restart.trigger-file` configuration property that is designed to address this issue. It makes the hot-restart only be performed when that particular file is touched.

Can I make IDEA touch a specific file at the end of the build process? Ideally, only if the build succeeded? Is there a plugin that can help me with it? Or is there a better way to configure IDEA (CE) for building and running Spring Boot applications?

13 comments
Comment actions Permalink

Thank you, will consider it.

Does anybody know how to touch a trigger file with the Community Edition? Ultimate is a bit beyond my budget right now.

0
Comment actions Permalink

Community edition doesn't provide Spring support

0
Comment actions Permalink

Hi,

 

1. I changed everything as described in this article: https://www.mkyong.com/spring-boot/intellij-idea-spring-boot-template-reload-is-not-working/

2. I tried with run/debug launch. 

3. I also tried with different options in Run/Debug Configurations > Spring Boot (below)

It doesn't work with IntelliJ Ultimate 2019.1. Anyone knows why?

 

 

 

 

0
Comment actions Permalink

What's the error that you get? Please share a sample project to reproduce the problem.

0
Comment actions Permalink

I don't have any error. I simply have to press Ctrl+F10 (Update) every time I want to see changes I made in any java file (ie. rest\FunRestController.java ).

 

After adding the following dependency in pom.xml I should have support for automatic reloading. Simply it doesn't work.

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

 

Project avaliable here: https://github.com/alfard1/springboot

1
Comment actions Permalink

As I see this is good when we don't want to restart frequently on each file modification. But in my case I want to restart on EACH file modification. So then no need for specify the spring.devtools.restart.trigger-file.

0
Comment actions Permalink

Then you need to change On Update action in the Run/Debug configuration to update classes and resources.

2
Comment actions Permalink

What is interesting, even after modification specified in this article still it doesn't work.

0
Comment actions Permalink

works! thank you Serge! :)

1
Comment actions Permalink

For me it only worked on debug mode.

0
Comment actions Permalink

Thanks Serge Baranov , you suggestion worked for me! 👍🏼

0

Please sign in to leave a comment.