pom.xml配置
<dependency> <!--实现springboot的热加载-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>true</scope>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!--springboot 热加载 fork : 如果没有该项配置,肯定devtools不会起作用,即应用不会restart -->
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
最后就回到我们的idea软件里
打开 Settings --> Build-Execution-Deployment --> Compiler,将 Build project automatically.勾上。
使用快捷键 Ctrl+Shift+A打开窗输入Registry
将 其中的compiler.automake.allow.when.app.running勾上
操作完毕以后,重启idea,然后在代码里任意修改下,看看是否有热加载了
本文详细介绍如何在SpringBoot项目中配置热加载功能,通过修改pom.xml文件引入spring-boot-devtools依赖,并设置spring-boot-maven-plugin插件的fork参数为true,确保IDEA中的自动编译选项已开启,实现代码修改后的即时热更新。
622

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



