【SpringBoot】热部署
spring-boot-devtools 方式
pom文件
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
application.properties
#热部署
spring.devtools.restart.enabled=true
spring.devtools.restart.additional-paths=src/main/java
#关闭缓存,及时刷新
#spring.thymeleaf.cache=false
#排除无需热部署目录
#spring.devtools.restart.exclude=static/**,public/**
#srping.devtools.restart.exclude=WEB-INF/**
IDEA 配置
1.Build project automatically
2.Shift+Ctrl+Alt+/ -> Registry -> compiler.automake.allow.when.app.running
参考:
https://www.cnblogs.com/jiangbei/p/8439394.html
https://blog.****.net/u012190514/article/details/79951258
https://blog.****.net/isea533/article/details/70495714
Spring Loaded 方式
pom 文件
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
</dependencies>
<!-- 入口函数不在根目录下进行如下配置 -->
<configuration>
<mainClass>com.xuxd.WebApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
启动方式
1.使用 spring boot:run 命令
2.配置 VM Options
参考:https://blog.****.net/x763795151/article/details/72852608
小结
推荐使用 spring-boot-devtools方式,支持的更多,同时Spring Loaded方式会产生端口占用的问题