4

我使用 Springboot 来创建我的应用程序,所以在 Springboot Doc 中说如果我使用 devtools,tomcat 将重新启动我的代码中的所有更改,但我使用 maven 面板来运行我的应用程序只需双击 spring-boot:run 插件,但是当我更改了我的 tomcat 不重新启动的任何代码。

我怎样才能解决这个问题?tks

4

4 回答 4

6

这是我前段时间用来使其工作的指南:https ://www.mkyong.com/spring-boot/intellij-idea-spring-boot-template-reload-is-not-working/

基本上你有两个做两件事:

  1. 从 Settings->Build, Execution, Deployment->Compiler启用“自动构建项目”
  2. 转到注册表(Ctrl+A,键入“注册表”)并启用compiler.automake.allow.when.app.runningide.windowSystem.autoShowProcessPopup
于 2017-08-11T17:27:02.493 回答
1

使用 IntelliJ IDEA,您需要在更改源代码后构建项目。

Build -> Build Project (Ctrl + F9)

这将触发重新启动。

于 2017-08-11T16:57:24.040 回答
0

根据:http ://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-devtools-restart

触发重启

由于 DevTools 监控类路径资源,触发重启的唯一方法是更新类路径。更新类路径的方式取决于您使用的 IDE。在 Eclipse 中,保存修改过的文件将导致类路径更新并触发重新启动。在 IntelliJ IDEA 中,构建项目(Build -> Make Project)将具有相同的效果。

因此,由于 IntelliJ 处理保存和构建的默认方式,您必须在应用程序运行时手动触发 IntelliJ 构建来编译和更新类路径。

另一种选择是在应用程序在 IntelliJ 中运行时启用自动构建。

需要注意的是,如果您是像我这样的 IntelliJ 用户,则需要在编译器首选项中启用“自动生成项目”才能使自动重启工作。您还需要在 IntelliJ 中启用 compiler.automake.allow.when.app.running 注册表设置。您可以使用快捷键 Shift+Command+A 在 IntelliJ 中访问注册表,然后搜索注册表。

https://patrickgrimard.io/2016/01/18/spring-boot-devtools-first-look/

于 2017-08-11T16:58:19.127 回答
0

就我而言,我正在使用这种对 maven 的依赖,它会执行评论中列出的操作,还可以启用实时重新加载

<!-- hot swapping, disable cache for template, enable live reload -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
于 2019-05-23T09:29:50.663 回答