使用IDEA配置项目热启动,不需要重启项目,就可以加载更新后的代码。
1 开启IDEA静态编译
选择工具栏 File -> Settings -> Build,Execution,Deployment -> Compiler,然后勾选 Build project automatically 。

2 开启IDEA的动态编译
同时按住 Ctrl + Shift + Alt + / 然后进入Registry :

勾选自动编译并调整延时参数:

compiler.automake.allow.when.app.running表示自动编译,需要勾选上;
compile.automake.trigger.delay 表示automake工具的延迟,设为100;
compile.document.save.trigger.delay 表示自动更新文件延迟,设为100;
3 开启IDEA的热部署策略
顶部菜单- >Edit Configurations:

将 On 'Update' action 和 On frame deactivation 均设为 Update class and resources:

4 在项目添加Maven依赖
在maven项目中的pom.xml中引入devtools依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
这样就实现了项目的热启动配置。
当项目在运行中时,若改动了部分代码,不需要重启项目,只需要切换到别的窗口等一秒钟,再切换回Idea,就可以实现项目的更新启动。