jrebel(http://zeroturnaround.com/)的作用就是當(dāng)你的代碼改變時(shí),你不需要重啟服務(wù),節(jié)省了時(shí)間。代碼的改變有很多種,比如增加class、在class中增加方法等等。下面介紹一下 Java 開發(fā)利器 intellij idea 怎樣安裝 jrebel。
1.安裝 jrebel 插件
在 intellij idea 中,打開 File - Settings(ctrl + alt + s),點(diǎn)擊彈出的對(duì)話框中的 plugins。
點(diǎn)擊對(duì)話框底部中間的按鈕 Browse repositories...,在彈出的對(duì)話框中可以搜索你需要的插件。我們搜索 jrebel。
搜索后,會(huì)顯示兩個(gè) jrebel 的插件。我們安裝 JRebel for Intellij,選中此插件,對(duì)話框右邊有個(gè)綠色的 install plugin 按鈕。點(diǎn)擊安裝即可。 安裝完成之后,需要重啟 intellij idea。
安裝好后,在 intellij idea 的右上角,有兩個(gè) jrebel 的圖標(biāo)。一個(gè)是正常啟動(dòng)模式,一個(gè)是 debug 模式。
2.破解 jrebel
jrebel唯一不好的地方就是收費(fèi)的
。對(duì)于我等屌絲的話,只能默默破解了。我現(xiàn)在jrebel使用的版本是6.2.5。
點(diǎn)擊這里,下載jrebel破解版。解壓破解文件后,將
1.安裝jr-ide-intellij-6.4.3_13-16.zip文件
2.jrebel.lic 復(fù)制到 C:\Users\你的用戶名\.jrebel 下
3.jrebel文件下的jrebel.jar 復(fù)制到 C:\Users\你的用戶名\.IntelliJIdea14\config\plugins\jr-ide-idea\lib\jrebel 下
4.jrebel6文件下的jrebel.jar 復(fù)制到 C:\Users\你的用戶名\.IntelliJIdea14\config\plugins\jr-ide-idea\lib\jrebel6 下
打開 intellij idea(如果破解的時(shí)候,你的 intellij idea 是打開的,則需要重啟),點(diǎn)擊 File - Settings(ctrl + alt + s),點(diǎn)擊 彈出對(duì)話框的 JRebel。右邊的 License 顯示 VALID,表示破解成功。恭喜!
設(shè)置:
因?yàn)橹挥衘rebel6被破解了,而選擇legacy agent就會(huì)沒(méi)有效果
3.使用 JRebel
打開 intellij idea 左下角的 JRebel 選項(xiàng)卡,這里可以看到你的項(xiàng)目。如果你的項(xiàng)目想使用jrebel,勾選項(xiàng)目下的復(fù)選框即可。
設(shè)置 tomcat 選項(xiàng),點(diǎn)擊 intellij idea 右上角。
在 彈出的對(duì)話框 中,修改 紅色框的內(nèi)容,保存即可。
點(diǎn)擊
中的一個(gè),啟動(dòng)服務(wù)吧。
服務(wù)啟動(dòng)后,當(dāng)你修改一個(gè)class 后,控制臺(tái) 顯示 JRebel: Reloading class ...,說(shuō)明 jrebel 已經(jīng)發(fā)揮作用了。
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
2015-10-20 更新
如果修改了 class,jrebel 沒(méi)有自動(dòng)部署。那就設(shè)置一下 代碼編譯 后的輸出目錄。
1.打開 項(xiàng)目結(jié)構(gòu)(ctrl + shfit + alt + s) 對(duì)話框,修改 class 的輸出目錄到 web 的 classes 下。
2.生成 jrebel 配置文件。在項(xiàng)目上右鍵 - jrebel - jrebel.xml。