Intellij IDEA springboot 开发工具

Intelijj IDEA springboot devtools

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

我该如何解决这个问题? 谢谢

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

Build -> Build Project (Ctrl + F9)

这将触发重启。

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

触发重启

As DevTools monitors classpath resources, the only way to trigger a restart is to update the classpath. The way in which you cause the classpath to be updated depends on the IDE that you are using. In Eclipse, saving a modified file will cause the classpath to be updated and trigger a restart. In IntelliJ IDEA, building the project (Build -> Make Project) will have the same effect.

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

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

One caveat if you’re an IntelliJ user like me, you’ll need to enable “Make project automatically” in the compiler preferences for automatic restarts to work. You’ll also need to enable the compiler.automake.allow.when.app.running registry setting in IntelliJ. You can access the registry in IntelliJ using the shortcut Shift+Command+A, then searching for registry.

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

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

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

  1. 从设置->构建、执行、部署->编译器
  2. 启用"Build project automatically"
  3. 转到注册表(Ctrl+A,键入 "Registry")并启用 compiler.automake.allow.when.app.runningide.windowSystem.autoShowProcessPopup

就我而言,我正在使用对 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>