相信不少人本身百度“idea springboot 热部署”
,找到的解决方案都是以下:html
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
spring
但其实这样设置,每次你改一点点代码,都会触发IDEA从新编译,IDEA变得很卡,开发体验很差。springboot
其实IDEA提供了对spring-boot-devtools
的相应支持的,打开IDEA——Help
在弹出网页中输入spring boot
,就能找到Configure application update policies with devtools这篇文档。app
实际操做:ide
1.在你的spring boot项目中引入依赖spring-boot-devtools
2.找到main方法,运行一下项目。注意必定要经过点击main方法运行
,而不能是经过mvn spring-boot:run
或gradle bootRun
,以下图:spring-boot
3.运行后咱们就能够打开Run
——Edit Configurations
,在SpringBoot
下设置On Update action
为Update classes and resources
,以下图:gradle
4.设置后,经过main方法运行,或者在菜单栏点击Run图标运行,如图:ui
5.当咱们修改完代码后,IDEA不会自动编译从新启动SpringBoot,而是咱们须要按一下左下角的Run
栏目中的Update xxx application
才会触发热切换。固然咱们也能够用快捷键ctrl+F10
。以下图:idea