在真实调试中,我们需要不断的调试程序,现在我希望,只要修改了文件,就自动编译重启,而不需要我们手动进行重启

添加devtools依赖到子工程中

注意:添加到子工程中即可,不需要在父工程中添加

  1. <dependency>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-devtools</artifactId>
  4. <scope>runtime</scope>
  5. <optional>true</optional>
  6. </dependency>

添加插件到父工程的pom文件中

<build>
  <plugins>
    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <configuration>
        <fork>true</fork>
        <addResources>true</addResources>
      </configuration>
    </plugin>
  </plugins>
</build>

使能自动编译

  • File->settings
  • 搜索compile,将A,B,C,D开头的全部勾选

1610803427854.png

设置更新值

ctril+shift+Alt + / , 选择Registry

勾选

  • compiler.automake.allow.when.app.running
  • actionSystem.assertFocusAccessFromEdt

重启IDEA并测试

在IDEA2020中默认情况下,修改文件不会立即从起,而需要过一会自动重启,你可以按ctril+F9立即重启