在pom.xml中
- dependencies标签
<!--springBoot工程实现热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
- build->plugins标签
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork><!--注意要修改这里-->
</configuration>
</plugin>
application.properties或者application.yml中禁用Thymeleaf,Freemarker,Groovy,Velocity模板缓存
spring.thymeleaf.cache=false
spring.freemarker.cache=false
spring.groovy.template.cache=false
spring.velocity.cache=false
开启自动编译
File->Other Settings->Default Settings找到全局设置界面 ->
Build,Execution,Deployment -> Compiler -> 勾选 Make project automatically(only works while not running / debugging)
修改idea行为
CTRL + SHIFT + A –>输入并进入Registry–>勾选 compiler.automake.allow.when.app.running
注意:开启热部署后不要频繁ctrl+s保存,因为一旦保存就会重新部署
Google Chrom浏览器中禁用缓存
CTRL+SHIIFT+J进入开发者界面中 -> Network 选项 -> 勾选Disable cache