开发时如果不能实现热部署其实是件挺坑爹的事情,如何频繁的重启服务器,势必要浪费大量的开发时间,配置好热部署,能大大减少时间的浪费,每次修改点东西还必须要手动重启,也影响开发效率和进度。使用idea热部署的具体配置如下:
1.设置pom.xml文件中相关配置:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 这个需要为 true 热部署才有效 -->
</dependency>
<dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
</configuration>
</plugin>
</plugins>
</build>
2.设置idea
①ctrl+alt+s 找到compiler属性,设置 自动编译 勾选 Build project automactically
② Ctrl + Shift + Alt + / 然后进入Registry ,勾选自动编译并调整延时参数。
OK,请重新启动,随便改值去测试一下吧~