Springboot热部署,搭配freemarker,完整方式
一、导入maven配置(加入以下两点)
<!--热部署-->
<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>
</plugins>
</build>
二、application.yml加入配置
spring: devtools: restart: #开启热部署 enabled: true additional-paths: src/main/java freemarker: request-context-attribute: req #req访问request suffix: .html content-type: text/html enabled: true cache: false #缓存配置 template-loader-path: classpath:/templates/ #模板加载路径 按需配置 charset: UTF-8 #编码格式 settings: number_format: 0.## #数字格式化,无小数点
三、设置idea自动部署
File-》Setting-》Compiler-Build Project automatically 打上勾
ctrl + shift + alt + /,选择Registry,勾上 Compiler autoMake allow when app running
修改类会重启,修改页面会重启,如果遇到修改页面不会重启的话,修改完按Ctrl F9,自动部署=-=。