一、开启项目静态自动编译
点击 File >>> Settings >>> Default Settings >>> Build >>> Compiler 勾选 Build project automatically
二、开启动态自动编译
同时按住 Ctrl + Shift + Alt + / 然后进入Registry ,勾选自动编译并调整延时参数,(延时参数也就是代码更改后多久开始重新启动)。
三、开启 Tomcat 编译 Class 和 resources
四、项目导入热部署的 pom 依赖:
如若不导入 pom 依赖也可以按住 Ctrl + shift + F9 进行快速跟新。
如果项目不是很大,只是简单写个Demo,我个人倾向于 使用devtools依赖,自动重启,方便简单不操心(笑)。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
如使用 thymeleaf 模板,记得在配置文件中关掉 thymeleaf 缓存。
application,yml:
spring:
thymeleaf:
cache: false