SpringBoot 实现热部署有哪几种方式

主要有两种方式:
Spring Loaded

Spring-boot-devtools

引用devtools依赖

org.springframework.boot spring-boot-devtools true

这样,当修改一个java类时就会热更新。

自定义配置热部署
以下配置用于自定义配置热部署,可以不设置。

# 热部署开关,false即不启用热部署
spring.devtools.restart.enabled: true

# 指定热部署的目录
#spring.devtools.restart.additional-paths: src/main/java


# 指定目录不更新
spring.devtools.restart.exclude: test

Intellij Idea修改
如果是idea,需要改以下两个地方:

1、勾上自动编译或者手动重新编译

File > Settings > Compiler-Build Project automatically
在这里插入图片描述

2、注册

ctrl + shift + alt + / 四个键

Registry > 勾选Compiler autoMake allow when app running
在这里插入图片描述

注意事项
1、生产环境devtools将被禁用,如java -jar方式或者自定义的类加载器等都会识别为生产环境。

扫描二维码关注公众号,回复: 5320429 查看本文章

2、打包应用默认不会包含devtools,除非你禁用SpringBoot Maven插件的 excludeDevtools属性。

3、Thymeleaf无需配置 spring.thymeleaf.cache:false,devtools默认会自动设置,参考完整属性。

转载https://mp.weixin.qq.com/s/uv8jIztilO_QvGc7qGhSAA

猜你喜欢

转载自blog.csdn.net/mingwulipo/article/details/87887960