JRebel熱部署
1.idea中安裝插件
File -> Settings -> Plugins -> Browse repositories 中 搜索 JRebel
,安裝 JRebel for IntelliJ
插件即可。
]
2.JRebel破解激活
JRebel並非免費的插件,需要激活之後才能使用。
2.1、首先到github上去下載一個反向代理軟件,我下載的是windows x64版本。
通過代理的方式激活
下載ReverseProxy_windows_amd64.exe軟件,點擊運行,激活過程不要關閉
雲盤鏈接 https://pan.baidu.com/s/1wQRXWSpU0VVzAEDvFDPI0Q
提取碼 w4py
雙擊運行下載的軟件
]
點擊激活出現下圖界面
]
激活地址
在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
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 重新構建項目中被修改的文件