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:run或gradle bootRun,如下图:


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

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

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

上一篇:Java数据结构及算法实例:插入排序 Insertion Sort
栏 目:JAVA代码
本文标题:Intellij IDEA下Spring Boot热切换配置
本文地址:http://www.codeinn.net/misctech/66140.html


阅读排行
- 1Java Swing组件BoxLayout布局用法示例
- 2java中-jar 与nohup的对比
- 3Java邮件发送程序(可以同时发给多个地址、可以带附件)
- 4Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Type异常
- 5Java中自定义异常详解及实例代码
- 6深入理解Java中的克隆
- 7java读取excel文件的两种方法
- 8解析SpringSecurity+JWT认证流程实现
- 9spring boot里增加表单验证hibernate-validator并在freemarker模板里显示错误信息(推荐)
- 10深入解析java虚拟机




