使用IDEA调试项目时,每次运行项目都需要1-2分钟,极大影响了调试效率,以下介绍一种通过springboot配置,实现热加载,具体过程如下:
- 引入相关依赖。打开pom文件,添加以下依赖
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>1.3.0.RELEASE</version>
<optional>true</optional>
</dependency>
- 开发环境设置
点击菜单file -> Settings打开对话框,选择Build,Execution,Deplyment—>Compiler,选中Build project automatically前的复选框,如下图所示  - 组合键:“Shift+Ctrl+Alt+/” ,选择 “Registry” ,弹出对话框,勾选 “compiler.automake.allow.when.app.running”,如下图所示:
 如果出现以下情况,是spring-boot-devtools版本不兼容问题  解决办法:修改pom.xml文件,去掉spring-boot-devtools版本信息,即将
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>1.3.0.RELEASE</version>
<optional>true</optional>
</dependency>
修改为:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
本文由宝鸡文理学院计算机学院软件培训服务中心彪晨曦同学整理
|