0
点赞
收藏
分享

微信扫一扫

Devtools&JRebel 热部署


Devtools
1、添加devtools依赖
在子module的POM文件添加依赖

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>

2、添加devtools插件
在父工程的POM文件添加插件

<build>
<!--finalName可以写可以不写-->
<finalName>SpringCloudDemo</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>

JRebel
1、安装插件

Devtools&JRebel 热部署_JRebel热部署


我安装的时候速度奇慢,等了好一会,安装完毕后点击重启。

CSDN审核不给我过如何激活的,我只能删了呜呜呜0.0,现在我就当你是激活状态的,想了解就只有私下找我了,或者查询其他文章,以前发布文章并没有被和谐。

接下来两步,对于两种热部署方式都需要配置

开启自动编译

Devtools&JRebel 热部署_热部署_02


开启自动运行

点击快捷键,ctrl+alt+shift+/,然后点击Registry

Devtools&JRebel 热部署_热部署_03

开启目标选项

Devtools&JRebel 热部署_JRebel热部署_04

重启idea即可

使用方法
Devtools实际上是一种假的热部署,只是在修改了代码后自动重启罢了,所以不推荐使用,这里不介绍

使用JRebel热部署需要使用JRebel来运行项目

Devtools&JRebel 热部署_JRebel热部署_05

测试一下第一次访问

Devtools&JRebel 热部署_热部署_06

修改一下代码

Devtools&JRebel 热部署_重启_07

ctrl+F9编译代码,控制台就会提示热部署的日志,再次访问

Devtools&JRebel 热部署_重启_08

Devtools&JRebel 热部署_JRebel热部署_09

对于小型项目,开启热部署作用不算明显,但是对于大型项目而言,代码调试阶段,运行代码所花时间会很多,如果采用热部署的话,会节约大量的时间

举报

相关推荐

0 条评论