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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章