AKSTIANYE

May 28, 2018

springboot devtools 热部署

添加pom依赖
1
2
3
4
5
6
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>runtime</scope>
</dependency>

maven plugin中添加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
<dependencies>
<!-- spring热部署-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.6.RELEASE</version>
<scope>provided</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
application.yml中添加
1
2
3
4
5
spring:
devtools:
restart:
#热部署生效
enabled: true

当我们修改了java类后,IDEA默认是不自动编译的,而spring-boot-devtools又是监测classpath下的文件发生变化才会重启应用

  • Ctrl+F9重新编译一下即可
  • 1. File>>Settings>>Build>>Compiler>>Build Project automatically
    2. ctrl + shift + alt + /,选择Registry,勾上 Compiler autoMake allow when app running
OLDER > < NEWER