SpringBoot热部署

来源:互联网 发布:普通网络作家没收入 编辑:程序博客网 时间:2024/06/03 16:38

step1、添加pom依赖

<dependency>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-devtools</artifactId>    <optional>true</optional></dependency>

step2、POM 文件添加插件

<plugin>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-maven-plugin</artifactId>    <configuration>        <!--fork :  如果没有该项配置devtools不会起作用,即应用不会restart -->        <fork>true</fork>        <addResources>true</addResources><!--支持静态文件热部署-->    </configuration></plugin>

step3、修改compiler

进入settings下,查找compiler,即Build,Exexcution,Deployment下的Compile下的选项:Make Project automaticaly

step4、修改Registry

windows下,快捷键ctrl+shift+A搜索Registry,找到compiler.automake.allow.when.app.running,开启此功能

macOS下,快捷键 shfit + command + a

PS

如果是thymeleaf渲染引擎,不要忘记在配置文件中设置缓存为false:

thymeleaf:encoding: UTF-8cache: falsemode: HTML5

下面就可以不用重启服务或者build就可以进行热部署了。