1、在pom.xml中添加依赖
<!--热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>
2、在application.yaml中配置devtools
spring:
devtools:
restart:
enabled:true
freemarker:
cache:false
3、idea中设置:File->Settings->Build_Execution_Deployment->Compiler,选中“Build project automatically”
4、在idea中,按Shift+Ctrl+Alt+/,会出现个弹窗,进入Registry,选中第一个选项
5、完成!