配置热部署需要引入一个组件:spring-boot-devtools(开发工具包)
添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-Devtools</artifactId>
<optional>true</optional>
</dependency>
在plugin中配置属性fork,并设置成true:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
使用Idea需要额外再进行配置
在设置中勾上“Build project automatically”:
使用快捷键Ctrl + Shift + A 搜索Registry,勾上compile.automake.allow.when.app.running。
至此,改动代码SpringBoot就会进行自动编译了,再也不需要重新部署了。