java - 从 2.1.13 升级到 2.2.0 后 Spring Boot 自动重新加载停止

标签 java spring-boot intellij-idea

以下是我的 POM 的相关部分

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.13.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

如你所见,我已经安装了开发工具。它在 2.1.13.RELEASE 版本上运行良好。当我在 Java 类中进行更改并在 Intellij IDEA 中点击“构建项目”时,服务器将按预期重新启动并进行新更改。

但是当我将 Spring Boot 版本升级到 2.2.0.RELEASE2.2.5.RELEASE 时,自动重启停止工作。当我进行更改并构建项目时,什么也没有发生。我检查了文档,根据该文档添加 devtools 依赖项应该足够了。

引用文档:https://docs.spring.io/spring-boot/docs/2.2.0.RELEASE/reference/pdf/spring-boot-reference.pdf (第37页)

更新 1:我创建了一个演示应用程序,供任何人尝试看看它是否适合他们。 Here's存储库。尝试使用 mvn spring-boot:run 运行它,并在运行时编辑 BookApi.java、重建,它应该会触发实时重启。

更新 2:以下是我启动应用程序时收到的日志:https://gist.github.com/lokeshh/d111c1429323ddf6e4a8d020526ceccb

更新 3:我尝试了 STS 4 来测试问题是否出在我的 IntelliJ 上。我发现 STS 4 中也存在同样的问题。保存后自动重新加载适用于 2.1.13,但不适用于 2.2.0。

更新4:删除了完整的.m2存储库,仍然是同样的问题。以下是启用了 devtools 跟踪的日志 https://gist.github.com/lokeshh/d111c1429323ddf6e4a8d020526ceccb#file-output_with_trace-log

最佳答案

嗯,它对我也有用,就像其他为你回答的人一样。

但是我在这里为你提供了解决方案。有时可能会发生。执行下面提到的步骤。

由于您已经在 pom.xml 中添加了依赖项,所以让我们进入下一步。

下一个

确认intellij中的设置。 。

=> 自动构建项目

文件 –> 设置 –> 构建、执行、部署 –> 编译器 –> 自动检查此构建项目

enter image description here

然后,检查Intellij 注册表

SHIFT+CTRL+A (Win/*nix) 或 Command+SHIFT+A (Mac) 打开弹出窗口,输入 注册表

enter image description here

找到并启用此选项compiler.automake.allow.when.app.running

enter image description here

完成。现在,应该启用热插拔和静态文件自动重新加载。

如果静态文件未重新加载,请按CTRL+F9强制重新加载。

  • /已添加帖子评论开发工具链接/

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-devtools-restart

关于java - 从 2.1.13 升级到 2.2.0 后 Spring Boot 自动重新加载停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60526897/

相关文章:

java - ImageIcon 在传递字符串参数时不显示图像

java - 动态规划斐波那契数列

java - 如何设置 IntelliJ IDEA 14 以在可能的情况下添加 "final"关键字?

java - spring-boot logback.xml 属性取决于配置文件

java - @Value 在 junit 5 中为 null

java - IntelliJ 如何知道目录是 'source' 还是 'test source'?

android - 未在Android Studio中加载Codenameone插件

java - 在 Android 中定期从服务器获取数据(轮询)

java - 是否在 UI 线程上调用了 Android.App.Application Activity 生命周期回调?

spring-boot - @WebMvcTest 是否需要 @SpringBootApplication 注释?