SpringBoot实现热部署
1. 前言
SpringBoot热部署的方式有三种,分别是使用Spring Loaded本地加载启动,使用SpringLoaded配置pom.xml文件和使用spring-boot-devtools。这里主要介绍使用spring-boot-devtools
2. 进行配置
2.1 Maven搜索依赖
Step1: 百度搜索Maven,点击Maven Repository
Step2: 搜索spring-boot-devtools,选择版本
Step3: 复制依赖
2.2 在pom.xml中导入依赖
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>2.5.2</version>
</dependency>
2.3 IDEA配置
File -> Settings -> Build, Execution, Deployment -> Compiler, 然后勾选Build project automatically
同时按下Ctrl + shift + Alt + / , 选择Registry, 勾上 compiler.automake.allow.when app.running
到此就完成了配置,重启项目即可