开发过程中的一点点改动需要重启项目是一件很烦的事情,浪费了很多时间。下面介绍Spring Boot本身提供一种非常简单的热部署方式。
# 添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
# yml配置文件
spring:
devtools:
restart:
#开启或关闭
enabled: true
#无需重启目录
exclude: static/**
#需重启目录
additional-paths: src/main/java
# IDEA中设置
- Preferences | Build, Execution, Deployment | Compiler | Build project automatically
- Ctrl+Shift+Alt+/ | Registry | compiler.automake.allow.when.app.running勾选