1. 页面热部署
-
pom.xml
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <!-- optional=true, 依赖不会传递, 该项目依赖devtools; 之后依赖boot项目的项目如果想要使用devtools, 需要重新引入 --> <optional>true</optional> </dependency> <!--thymeleaf模块引擎--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <!--freemarker模块引擎--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> </dependency>
-
application.yml
spring:
#两个不同模板
thymeleaf:
cache: true #如果开启此处会导致每次输入删除都会自动刷新哪怕你没保存
freemarker:
# #页面不加载缓存,修改即时生效
cache: false
2. Java热部署
-
pom.xml引入依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>
-
application.yml
-
设置idea中支持自动编译
1.开启自动编译
Preferences | Build, Execution, Deployment | Compiler -> 勾选上 Build project automatically 这个选项
2.开启允许在运行过程中修改文件
ctrl + alt + shift + / ---->选择1.Registry —> 勾选 compiler.automake.allow.when.app.running 这个选项
3. jsp热部署
-
pom.xml
<dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> </dependency>
-
application.yml
#新版本的Spring Boot
server:
port: 8081
servlet:
jsp:
init-parameters:
development: true