目录
SpringBoot因为没有外部容器的支持,而且使用gradle去构建项目,再加上idea默认不会自动编译的特性,当我们修改jsp页面或者thymeleaf页面时都需要重启项目,这十分麻烦和不便于开发,所以需要进行热部署。详细的方案说明可以参考spring官方文档:https://docs.spring.io/spring-boot/docs/current/reference/html/howto-hotswapping.html
更多关于SpringBoot的总结请点击:SpringBoot使用总结
一、开发环境
idea+gradle+springboot
二、配置热加载
1、开启热加载
在build.gradle文件根节点中加入
bootRun {
//开启页面热加载功能
addResources = true
}
2、添加依赖
在build.gradle文件dependencies下加入热部署依赖
compile("org.springframework.boot:spring-boot-devtools")
3、开启IDEA自动编译
4、修改idea相关配置
按下
ctrl + alt + shift + /
点击Registry,勾选compiler.automake.allow.when.app.running
5、修改thymeleaf配置
配置thymeleaf.cache为false,不要缓存
spring.thymeleaf.cache=false
参考:https://www.cnblogs.com/linkstar/p/8245480.html