IDEA下Spring Boot热切换 Intellij IDEA下Spring Boot热切换配置

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

IDEA下Spring Boot热切换 Intellij IDEA下Spring Boot热切换配置

煲煲菜   2021-03-31 我要评论

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

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

2.IDEA按ctrl+alt+s——Build,Excution,Deployment——Compiler——勾选Build project automatically

3.IDEA按ctrl+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,如下图:

3.运行后我们就可以打开Run——Edit Configurations,在SpringBoot下设置On Update actionUpdate classes and resources,如下图:

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

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

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

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们