Intellij IDEA下Spring Boot热切换配置

这篇文章主要介绍了Intellij IDEA下Spring Boot热切换配置,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

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

以上就是Intellij IDEA下Spring Boot热切换配置的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » Java