OR博客
SpringBoot热部署
OrdinaryRoad
创建于:2020-08-21 22:28:27
0
25
105
0
在使用IDEA开发SpringBoot的时候,可以进行一些设置,使新功能的生效更加快捷
# 使用方法 ## 1.增加DevTools的依赖 maven ``` <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> </dependencies> ``` ## 2.打开Build project automatically选项 使用 `Ctrl`+`Alt`+`S`进入设置,然后找到Compiler选项,勾选Build project automatically选项 ## 3.打开IDEA的Registry中的compiler.automake.allow.when.app.running选项 [IntelliJ IDEA新版本中compiler.automake.allow.when.app.running不存在的问题 - SpringCore - 博客园 (cnblogs.com)](https://www.cnblogs.com/fanqisoft/p/15200894.html) > 很多文章介绍IntelliJ IDEA开启热部署功能都会写到在IntelliJ IDEA中的注册表中开启compiler.automake.allow.when.app.running选项,此选项在IntelliJ IDEA 2021.2之后的版本迁移到高级设置中。 > > ![image.png](https://oss.ordinaryroad.top/api/download/thumbnail/2021-10-21/image.png) 先使用 `Ctrl`+`Alt`+`Shit`+`/`,在弹出的选项框中选择第一项,然后回车,然后勾选compiler.automake.allow.when.app.running选项 ![](https://api.ordinaryroad.tech/upms/file/download/ordinaryroad-blog/before-refactor/picture/8e613ce3c52b412789452066a433c8b4d01b/Registry.jpg) # 使用效果 当以上改动都生效后,在修改完某个类后,如果切出IDEA界面,比如切换到浏览器,IDEA就会自动对比文件是否改动,然后重新编译部署,使用这种方法base classloader不会重新加载,因此比stop后重新run更快。 # 参考资料 [SpringBoot官网文档关于Developer Tools部分的介绍](https://docs.spring.io/spring-boot/docs/current/reference/html/using-spring-boot.html#using-boot-devtools "SpringBoot官网文档关于Developer Tools部分的介绍") [b站最强新版Springboot教程 全程有废话我直播吃纸.p11-p12](https://www.bilibili.com/video/BV17z4y1X7is/?p=11 "b站最强新版Springboot教程 全程有废话我直播吃纸")
评论
楼主暂时不想被别人评论哦~