1、添加DevTools依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
2、设置自动编译,勾选自动编译Build project automatically
3、设置Idea的Registry(快捷键Ctrl+Shift+Alt+“/”),找到complier.automake.allow.when.app.running 并勾选
勾选后关闭即可