当前位置: 移动技术网 > IT编程>开发语言>Java > Intellij IDEA下Spring Boot热切换配置

Intellij IDEA下Spring Boot热切换配置

2019年07月19日  | 移动技术网IT编程  | 我要评论

相信很多人自己百度“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。如下图:

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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网