1、添加热部署依赖
在 Spring Boot项目进行热部署测试之前,需要先在项目的pom.xml 文件中添加热部署依赖,具体代码如下。
<!--引入热部署依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
2、设置启动热部署
在IDEA 的菜单栏中依次选择"File"->"Setings",进入IDEA 的设置对话框,然后选择"Build,Execution,Deployment"的"Compiler"选项,如图所示。在右侧勾选"Build project automatically"选项将项目设置为自动编译,然后单击"Apply"→"OK"按钮保存设置。
在 IDEA 的设置对话框中选择"Advanced Settings"选项,如图所示。在右侧勾"Compiler"下的"Allow auto-make to start even if developed application is currently running"选项,允许自动启动当前正在运行的应用程序,然后单击"Apply"→"OK"按钮保存设置。
至此,在Spring Boot项目中的热部署已经部署完成。