回到主题,这一次我决定使用JRebel,这一次我花了比较多的时间来摆弄配置.现在的环境是Mac上面使用IntelliJ作为IDE,同时使用Jetty作为服务器,Ant作为构建工具.整个流程是,
第一步:找到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”
第一步:找到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”