IDEA配置springboot热部署

IDEA配置springboot热部署

步骤一:开启IDEA的自动编译(静态)

file -> setting -> Build,Execution,Deployment -> Compiler -> 勾选 Build project automatically
在这里插入图片描述

步骤二:开启IDEA的自动编译(动态)

按住 Ctrl + Shift + Alt + / 然后进入Registry ,勾选自动编译并调整延时参数

  • compiler.automake.allow.when.app.running -> 自动编译
  • compile.document.save.trigger.delay -> 自动更新文件

网上极少有人提到compile.document.save.trigger.delay 它主要是针对静态文件如JS CSS的更新,将延迟时间减少后,直接按F5刷新页面就能看到效果!
在这里插入图片描述

步骤三:开启IDEA的热部署策略(非常重要)

具体步骤:顶部菜单- >Edit Configurations->SpringBoot插件->目标项目->勾选热更新。

在这里插入图片描述

步骤四:添加依赖

<!--添加热部署-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
            <scope>true</scope>
        </dependency>
<plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <!--热部署配置-->
                <configuration>
                    <!--fork:如果没有该项配置,整个devtools不会起作用-->
                    <fork>true</fork>
                </configuration>
            </plugin>

版权声明:本文为weixin_41844824原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。