近期新接触了一个项目,IDEA开启自动编译后热部署也不生效.很纳闷儿,因为之前的项目是可以热部署的.后来搜了几篇博客之后终于解决了问题,于是有了这篇博客.
1、添加maven依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 这个需要为 true 热部署才有效 -->
<scope>true</scope>
</dependency>
2、插件配置
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!-- 没有该配置,devtools 不生效 -->
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
3.开启IDEA的自动编译(如果已经设置过了就没必要往下看了)
(1) File---Settings---Compiler---Build Project automatically
或者:快捷键 Ctrl+Alt + S ---Compiler---Build Project automatically
(2) Ctrl + Shift + Alt + /, 选择Registry,然后勾上 Compiler autoMake allow when app running