Intellij Idea Spring Boot 热部署

  1. 勾选
    Intellij Idea Spring Boot 热部署
  2. 在POM文件中添加依赖
    <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-devtools</artifactId>
       <optional>true</optional>
    </dependency>

  3. 在POM文件中添加插件
    <plugin>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-maven-plugin</artifactId>
       <configuration>
          <!--fork :  如果没有该项配置devtools不会起作用,即应用不会restart -->
          <fork>true</fork>
          <addResources>true</addResources><!--支持静态文件热部署-->
       </configuration>
    </plugin>

  4. 网上很多教程没有这一步,我没有这一步是不行的。
    Windows 是 Shift+Ctrl+Alt+/,Mac把Ctrl改为command 。选择Registry
    Intellij Idea Spring Boot 热部署
    然后勾选
    Intellij Idea Spring Boot 热部署
    重启。就可以了