1.在pom.xml上添加依赖
org.springframework.boot spring-boot-devtools
2. 中文翻译后选择自动构建项目。英文具体步骤:打开顶部工具栏 File -> Settings -> Default Settings -> Build -> Compiler 然后勾选 Build project automatically 。
3. IDEA2021版本在开启
老版本使用CTRL+shift+alt+/进入Registry 勾选compiler.automake.allow.when.app.running即可开启热部署
附:
在配置文件中使添加可以设置热部署作用范围
# 热部署范围配置
devtools:
restart:
# 设置不参与热部署的文件和文件夹(即修改后不重启)
exclude: static/**,public/**,config/application.yml
#是否可用
# enabled: false
在引导类中使用 System.setProperty("spring.devtools.restart.enabled", "false");可以设置热部署优先级比配置文件更高
@SpringBootApplication
public class SSMPApplication {
public static void main(String[] args) {
// 这里设置关闭热部署,优先级比配置文件高,防止配置文件多的时候找不到对应的热部署配置
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(SSMPApplication.class, args);
}
}
暑期编程PK赛 得CSDN机械键盘等精美礼品!



