idea设置热启动
1.pom 中加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
- application.properties 中加入热部署配置:
# 开启热部署
spring.devtools.restart.enabled=true
#重启目录
spring.devtools.restart.additional-paths=src/main/java
#classpath目录下的templates文件夹内容修改不重启
spring.devtools.restart.exclude=templates/**
1 修改Settings里Compiler选项下的配置,将下图中红色方框里的选项全部勾上
2 修改Advanced Settings里的配置,将下图中红色方框里的选项勾上
注意 Advanced Settings选项只有在File->Settings里面才有,而在File->New Projects Setup->Settings for New Projects这个设置页面里是没有的,所以只能设置本项目,而不能自动设置新建的项目。
IDEA 2021.2 版本将Registry里的compiler.automake.allow.when.app.running的选项放到了Advanced Settings里,所以像旧版本的解决方案就不适用了。如果使用的是IDEA 2021.2之前版本的话还是使用快捷键shift+Ctrl+Alt+/,选择Registry…,将compiler.automake.allow.when.app.running选项勾上。