一共需要两个步骤:
- 第一步、先设置我们的pom.xml文件,加入依赖
首先是把下面代码在中
<!--添加热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>true</scope>
</dependency>
另外下面的代码是放在 下面里的
<plugin>
<!--热部署配置-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--fork:如果没有该项配置,整个devtools不会起作用-->
<fork>true</fork>
</configuration>
</plugin>
- 第二步、设置IDEA的自动编译:
(1)File-Settings-Compiler勾选 Build Project automatically
2)快捷键 ctrl + shift + alt + /,选择Registry,勾上 Compiler autoMake allow when app running
这样我们的热部署就完成了,重启一下项目,然后修改了类或者html、js等内容,IDEA就会自动去make了。