Spring Boot 热部署即避免服务频繁的重启启动的一种策略,可以在修改代码之后自动部署服务,避免重启。 1. pom.xml 配置
dependencies:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>true</scope>
<optional>true</optional>
</dependency>
plugins:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
2. application.yml 配置
debug: true
spring:
devtools:
restart:
enabled: true #设置开启热部署
freemarker:
cache: false #页面不加载缓存,修改即时生效
3. settings 设置
settings -> build,execution,deployment -> compiler
build project automatically #勾选
4. registry 设置
Ctrl+Shift+Alt+ /
compiler.automake.allow.when.app.running #勾选
5. 启动程序 修改接口内容,等待2秒左右会自动启动热部署