【Spring Boot】IntelliJ IDEA实现Spring boot热部署
原因:IntelliJ IDEA 默认不能自动编译,因此只对Spring项目引入pring-boot-devtools的依赖不能成功进行热部署。


解决方法如下:
1. CTRL + SHIFT + A --> 查找make project automatically --> 选中 

【Spring Boot】IntelliJ IDEA实现Spring boot热部署
 


2. CTRL + SHIFT + A --> 查找Registry --> 找到并勾选compiler.automake.allow.when.app.running

【Spring Boot】IntelliJ IDEA实现Spring boot热部署
 


3.引入依赖
(1)加maven依赖
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional><!-- optional=true,依赖不会传递,该项目依赖devtools;之后依赖该项目的项目如果想要使用devtools,需要重新引入 -->


</dependency>


(2)开启热部署
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>


4.浏览器禁用缓存(如Chrome/360浏览器等)
F12(或Ctrl+Shift+J或Ctrl+Shift+I)--> NetWork --> Disable Cache(while DevTools is open)


 【Spring Boot】IntelliJ IDEA实现Spring boot热部署


5.重新启动项目即可成功进行热部署

相关文章:

  • 2022-12-23
  • 2021-11-25
  • 2022-01-01
  • 2022-01-12
  • 2021-07-22
  • 2022-01-04
  • 2021-06-13
  • 2022-12-23
猜你喜欢
  • 2021-11-26
  • 2021-04-15
  • 2021-08-19
  • 2022-01-12
  • 2022-02-23
相关资源
相似解决方案