第一步:找到build.xml中啓動Jetty的代碼,添加JVM參數.(現不討論它的工作機制)
view sourceprint?1 <jvmarg line="-noverify -javaagent:/Users/twer/jrebel.jar" />
你需要設定-javaagent到你的jrebel.jar所在的路徑,我這裏只是做測試spike.
第二步:你需要給你的IDE按照JRebel的插件,用來產生rebel.xml的描述,來描述你想監視的目錄.我想說得顯然的是JRebel插件在我的電腦上不管用,產生的rebel.xml文件都是空的,需要自己來寫. 你需要將rebel.xml放在你平常放.properties文件的目錄,也就是src目錄下.下面是我的描述文件:
view sourceprint?01 <?xml version="1.0" encoding="UTF-8"?>
02 <application
03 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
04 xmlns="http://www.zeroturnaround.com"
05 xsi:schemaLocation="http://www.zeroturnaround.com http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd">
06 <classpath>
07 <dir name="/Users/twer/Workspace/TWU/chronicles/web/WEB-INF/classes">
08 <!-- Only include package1 and its subpackages -->
09 <include name="chronicles/**"/>
10 </dir>
11 </classpath>
12 </application>
顯然dir也就是你想監視的目錄顯然不應該像上面一樣硬編碼,而且我只想監視WEB-INF/classes下的chronicles目錄下的文件.
第三步: 實現到現在後,你還需要首先開啓”編譯時同時編譯所依賴的文件” 選項,這個選項在”Preference”.
Make sure all dependent files are also compiled.
Settings–>Project Setting–> Compiler –>Honor dependencies on command
第四步:你還需要修改你項目的編譯的輸出路徑,
change the output of compile on Module Settings “Module”->”Paths”->check “Use module compile output path” 將其輸出路徑指向你在rebel.xml所監視的目錄.
第五步:到這一步,你基本上基本配置完成了,但是每次你修改完.java文件,你本能按下”CTR+S”保存,但是更多的時候希望當你保存時它會自動編譯,所以你需要配置你的快捷鍵,
Overwrite default Save to Compile
Start using the default compile shortcut Ctrl-Shift-f9 or map it to Ctrl-s (files get still saved).
Steps: “File” –>”Settigns” –>”Keymap” –>in the right window click ”Copy ”–> then find “Main Menu” and click “File” below it–>Change “Save” to another key –> back to”Main Menu” and click “Build” –>find “Compile” and change key to “Ctr+S”