简体   繁体   中英

Spring boot hot reloading does not work in InteliJ

I would like to have spring boot auto restart the server when my classes are updated. I already have seen the following answer:

How does Spring Boot load changes in code without restarting the server

My pom file has the following dependency:

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

I have the following settings enabled in Intelij:

在此处输入图像描述

And also:

在此处输入图像描述

When I now spin up the server I get the following:

Notice in the logs:

2021-12-18 15:18:42.624 INFO 4204 --- [ restartedMain] osbdaOptionalLiveReloadServer: LiveReload server is running on port 35729

But now when I make changes to any of the files in the package where my main method is and subpackages (for example: Test controller) my server does not get reloaded.

在此处输入图像描述

Any ideas how to fix this?

As the IntelliJ Edition Comparison shows, Community Edition doesn't "support":

Spring, Jakarta EE, Java EE, Micronaut, Quarkus, Helidon and more...

We can (little ugly, because an exception "flies", the restart happens (at least)2 times..depending how long the build/compilation takes) "hack".

Running a maven spring-boot:run configuration , we can:

  • (better) Deactivate the shown settings: Save on Compile, "Allow auto make on running..." (we can also leave, but the result/number of restarts will be less predictable:)
  • Trigger an (additional) "(Re-)build module/project" build, or a mvn process-classes (or something, that "touches the classpath").

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM