JRebel热部署

JRebel热部署

1.idea中安装插件

File -> Settings -> Plugins -> Browse repositories 中 搜索 JRebel,安装 JRebel for IntelliJ 插件即可。

1568699771415]

2.JRebel破解激活

JRebel并非免费的插件,需要激活之后才能使用。

2.1、首先到github上去下载一个反向代理软件,我下载的是windows x64版本。

通过代理的方式激活

下载ReverseProxy_windows_amd64.exe软件,点击运行,激活过程不要关闭
云盘链接 https://pan.baidu.com/s/1wQRXWSpU0VVzAEDvFDPI0Q
提取码 w4py

双击运行下载的软件

1568699771415]

点击激活出现下图界面

1568699771415]

激活地址

在http://127.0.0.1:8888/地址后拼接32位随机字符串保证唯一性即可

例如:http://127.0.0.1:8888/88414687-3b91-4286-89ba-2dc813b107ce

邮箱地址随意填写,注意格式正确。再点击以下change liense 按钮验证激活 。

JRebel设置为offline模式(即为离线模式,否则反向代理软件关闭或断网则插件不可用)

点一下work offline
在这里插入图片描述

3激活完成后,打开idea->settings

在这里插入图片描述

勾选 Build project automatically,点击apply和OK。

按组合键 Shift+Ctrl+Alt+/,选择Registry,勾选上compiler.automake.allow.when.app.running
在这里插入图片描述

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存失败,源站可能有防盗链机制,建议将图片保存下来直接上传下上传(iOj4Q9hbvcan-1584859271986)(https://gitee.com/zhaoguoxin/leran_images_bin/typora-user-images\1562368)841873.png(ttps://gitee.com/zhaoguoxin/leran_images_bin/typora-user-images\1568698841873.png)]]

3.1 配置JRebel Maven插件

官方文档:https://manuals.zeroturnaroun…

JRebel Maven插件的目的是在Maven构建期间为您的项目生成rebel.xml文件。

对于Maven项目 特别是在多模块项目的情况下 使用JRebel Maven插件生成rebel.xml配置文件很方便。将以下代码段添加到您的父级pom.xml。该rebel.xml配置文件可以在你的Maven项目的每个单独的子模块产生。

maven 下载 plugin包

<!--jrebel插件-->
        <plugin>
          <groupId>org.zeroturnaround</groupId>
          <artifactId>jrebel-maven-plugin</artifactId>
          <version>1.1.9</version>
            <configuration>
            <!-- 将配置的资源目录也添加到rebel.xml中 -->
            <addResourcesDirToRebelXml>true</addResourcesDirToRebelXml>
            <!--如果设置为true,则生成的rebel.xml将在构建期间在控制台中打印出来,可以立即看到生成的内容。默认为false-->
            <showGenerated>true</showGenerated>
            <!-- 每次都生成新的rebel.xml。如果为false,只在rebel.xml和pom.xml的时间戳不相同的时候,重新生成rebel.xml。默认为false -->
            <!--<alwaysGenerate>true</alwaysGenerate>-->
            <!-- 在单个项目中处理多个模块时,您可以选择跳过为特定模块生成rebel.xml。 只需将以下内容添加到他们的pom.xml中即可 -->
            <!--<skip>true</skip>-->
            <!-- 如果工程师自己自定义的package,则需要主动设置为 jar 或者 war -->
            <!--<packaging>war</packaging>-->
            </configuration>
          <executions>
            <execution>
              <id>generate-rebel-xml</id>
              <phase>process-resources</phase>
              <goals>
                <goal>generate</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

配置结束后执行命令mvn jrebel:generate

生成在target中生成 rebel.xml

<?xml version="1.0" encoding="UTF-8"?>

<!--
  This is the JRebel configuration file. It maps the running application to your IDE workspace, enabling JRebel reloading for this project.
  Refer to https://manuals.zeroturnaround.com/jrebel/standalone/config.html for more information.
-->
<application generated-by="maven" build-tool-version="3.2.2" plugin-version="1.1.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_2.xsd">
	<classpath>
		<dir name="F:/project/shop1905/src/main/resources">
		</dir>
		<dir name="F:/project/shop1905/target/classes">
		</dir>
	</classpath>

	<web>
		<link target="/">
			<dir name="F:/project/shop1905/src/main/webapp">
			</dir>
		</link>
	</web>

</application>

4.推荐用法

4.1选中要热部署的项目
在这里插入图片描述

启动项目和debug项目
在这里插入图片描述

修改代码后通过Ctril+F9 重新构建项目中被修改的文件

发布了10 篇原创文章 · 获赞 1 · 访问量 4161
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章