SpringBoot实现热部署
SpringBoot实现热部署
① 在pom.xml中添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>2.1.3.RELEASE</version>
//不传递依赖
<optional>true</optional>
</dependency>
② 添加spring-boot-maven-plugin
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
//如果没有该项配置,devtools不会起作用,即应用不会restart
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
③ 修改application.properties文件
//热部署生效
spring.devtools.restart.enabled=true
//设置重启的目录
spring.devtools.restart.additional-paths=sr
//statics文件夹下内容修改不重启(文件夹必须存在)
spring.devtools.restart.exclude=statics/**
④ 修改idea配置
-
ctrl + shift + alt + / ===> Registry ===> 勾选compiler.automake.allow.when.app.running
-
File-Settings-Compiler-Build Project automatically