我们在开发中反复修改类、页面等资源,每次修改后都是需要重新启动才生效,这样每次启动都很麻烦,浪费了大量的时间,我们可以在修改代码后不重启就能生效,在 pom.xml 中添加如下配置就可以实现这样的功能,我们称之为热部署。
在pom.xml 中引入依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
eclipse可以直接使用了
DEA进行SpringBoot热部署失败
出现这种情况,并不是热部署配置问题,其根本原因是因为Intellij IEDA默认情况下不会自动编译,需要对IDEA进行自动编译的设置如下:
1) “File” -> “Settings” -> “Build,Execution,Deplyment” -> “Compiler”,选中打勾 “Build project automatically” 。

2) 组合键:“Shift+Ctrl+Alt+/” ,选择 “Registry” ,选中打勾 “compiler.automake.allow.when.app.running” 。


这样设置好就可以用了

本文详细介绍如何在SpringBoot项目中配置热部署,避免每次代码修改后都需要重启服务器的繁琐过程。通过在pom.xml中添加spring-boot-devtools依赖,结合Eclipse或IntelliJ IDEA的自动编译设置,实现代码修改后的即时生效。
1031

被折叠的 条评论
为什么被折叠?



