Intellij IDEA下Spring Boot热切换配置

2025-05-29 0 47

相信很多人自己百度idea springboot 热部署”,找到的解决方案都是如下:

1.项目加入依赖spring-boot-devtools

2.ideactrl+alt+s——build,excution,deployment——compiler——勾选build project automatically

3.ideactrl+shift+a——输入registry——compiler——勾选compiler.automake.allow.when.app.running

但其实这样设置,每次你改一点点代码,都会触发idea重新编译,idea变得很卡,开发体验不好。

其实idea提供了对spring-boot-devtools的相应支持的,打开idea——help在弹出网页中输入spring boot,就能找到configure application update policies with devtools这篇文档。

实际操作:

1.在你的spring boot项目中引入依赖spring-boot-devtools

2.找到main方法,运行一下项目。注意一定要通过点击main方法运行,而不能是通过mvn spring-boot:rungradle bootrun,如下图:

Intellij IDEA下Spring Boot热切换配置

Intellij IDEA下Spring Boot热切换配置

3.运行后我们就可以打开run——edit configurations,在springboot下设置on update actionupdate classes and resources,如下图:

Intellij IDEA下Spring Boot热切换配置

4.设置后,通过main方法运行,或者在菜单栏点击run图标运行,如图:

Intellij IDEA下Spring Boot热切换配置

5.当我们修改完代码后,idea不会自动编译重新启动springboot,而是我们需要按一下左下角的run栏目中的update xxx application才会触发热切换。当然我们也可以用快捷键ctrl+f10。如下图:

Intellij IDEA下Spring Boot热切换配置

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持快网idc。

原文链接:https://segmentfault.com/a/1190000015930347

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 Intellij IDEA下Spring Boot热切换配置 https://www.kuaiidc.com/111546.html

相关文章

发表评论
暂无评论