IDEA-SpringBoot热部署失效问题解决

热部署的作用

springboot每次修改之后都需要重新启动才会生效,启动热部署之后每次修改会自动重启,而不用手动重启,提高开发效率。

1.添加依赖

  1.  
    <!-- SpringBoot热部署 -->
  2.  
    <dependency>
  3.  
    <groupId>org.springframework.boot</groupId>
  4.  
    <artifactId>spring-boot-devtools</artifactId>
  5.  
    <optional>true</optional>
  6.  
    <scope>true</scope>
  7.  
    </dependency>

2.添加插件

  1.  
    <build>
  2.  
    <plugins>
  3.  
    <plugin>
  4.  
    <groupId>org.springframework.boot</groupId>
  5.  
    <artifactId>spring-boot-maven-plugin</artifactId>
  6.  
    <configuration>
  7.  
    <!--没有配置该选项devtools不起作用,即应用不会restart-->
  8.  
    <fork>true</fork>
  9.  
    </configuration>
  10.  
    </plugin>
  11.  
    </plugins>
  12.  
    </build>

3.设置application.properties

spring.devtools.restart.enabled=true

4.开启自动编译

  • Ctrl+Alt+S打开配置
  • 设置自动编译

     

    设置

  • Ctrl+Shift+Alt+? 选择Registry

     

    Maintenance

  • 找到选项打勾

     

原文地址:https://www.cnblogs.com/curedfisher/p/14086652.html