首先说一下thymeleaf的html页面热加载
1.加入thymeleaf依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2.修改thymleaf模板配置
#thymelea模板配置
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.cache=false #主要是这里,设置默认不缓存页面
spring.resources.chain.strategy.content.enabled=true
spring.resources.chain.strategy.content.paths=/**
3.最后在每次修改静态内容时按Ctrl+Shift+F9
即可重新加载
其次说一下idea中springboot的热加载设置
1.首先加入开发工具依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
2.其次在build maven插件中开启热部署
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork> #主要是这里,开启
</configuration>
</plugin>
</plugins>
</build>
3.idea开启自动
我这里用的是idea2018,老的版本都在这个位置,只是名字不一样,大家自己修改
4.Shift+ALT+Ctrl+/
找到进入 registry
并勾选compiler.automake.allow.when.app.running
5.禁用浏览器缓存 按F12(更多工具—->开发者工具),找到network,勾选Disable Cache
至此就可以完成整个项目的热加载了