osznhimzap 发表于 2016-5-17 12:24:16

JRebel MAC IDEA热加载

前言:
JRebel安装、破解、本地和远程热加载。
 
环境:
MAC OS X 10.10,IDEA 13, JRebel 6,Tomcat 6
 
1、下载
JRebel破解:地址
文件名:jrebel6.0.0-crack.zip(人家让加微信下,就支持一下好了)
 
IDEA插件:地址

 
文件名:jr-ide-idea-6.0.0-idea13__1_.zip
 
以上下载的都是JRebel6.0.0相关版本
 
2、安装IDEA插件
a.快捷键“command+, ”打开Preferences,在左侧找到Plugins并选中,点击“Install plugins from disk...”按钮。在打开的对话中找到你下载到本地的jr-ide-idea-6.0.0-idea13__1_.zip(不用解压),然后点击“Choose"-->"OK"-->"Restart"。


 
b.安装完后按提示重启。
  c.关掉IDEA,解压下载的jrebel6.0.0-crack.zip,把jrebel6.0.0-crack中的jrebel.jar,替换掉如下路径中的jrebel.jar(里面还有个jrebel.lic文件,后面激活用)。
  /Users/youname/Library/Application Support/IntelliJIdea13/jr-ide-idea/lib/jrebel
  注意:以上路径是插件安装后的目录,youname是你本机的登录名。
  d.打开IDEA,然后快捷键“command+, ”打开Preferences,在左侧找到JRebel并选中。打开如下图的激活窗口,找到并选择c步下的jrebel.lic。
 

 
现在插件安装并破解成功,如下图。
 

 
3、本地使用(指tomcat在IDE中拉起):
a.新建一个web工程(见附件,maven工程的,可直接导入)
b.配制Tomcat Server(local)(先保证本地的tomcat能拉起并正常运行,略)
c.操作过程,如图:


 


 
4、远程使用(服务器不在本地,或在IDE外拉起tomcat):
a.把jrebel6.0.0-crack中的jrebel.jar复制到tomcat根目录下,如/usr/local/apache-tomcat-6.0.37
b.修改tomcat的catalina.sh文件,位置如:/usr/local/apache-tomcat-6.0.37/bin/catalina.sh
 

JAVA_OPTS="$JAVA_OPTS -javaagent:/usr/local/apache-tomcat-6.0.37/jrebel.jar -Drebel.remoting.persistent=true -Drebel.remoting_plugin=true"
 追加如上代码,注意真实path:-javaagent:/usr/local/apache-tomcat-6.0.37/jrebel.jar  
   
c.修改tomcat的server.xml文件,位置如/usr/local/apache-tomcat-6.0.37/conf/server.xml
 

<!-- 以下为追加
/Users/yangqi/svn/testweb/target/testweb 要改成你的路径-->
<Host name="localhost" appBase="deploy" unpackWARs="true" autoDeploy="false">
<Context path="/" reloadable="true" docBase="/Users/youname/svn/testweb/target/testweb" workDir="/usr/local/apache-tomcat-6.0.37/work"/>
 
<!-- 这里注释掉 -->
<!--<Host name="localhost"appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">-->
 
 d.IDE中配置  





 e.maven中执行package(略,上有例)(原理是要把自动生成的rebel.xml和rebel-remote.xml打到war中)


f.终端中启动tomcat(不在IDE中启动,表示是一个远程的服务)

g.在IDE中执行如下操作。



 

h.查看tomcat/logs/catalina.out 输出。如下,表示成功:



 

  

其他:

上面我们在JAVA_OPTS中加了-Drebel.remoting.persistent=true,这会造成应用mvn clean package后,重运行时仍是上次Synchronous module时的代码。就算再清掉tomcat的work和temp目录也无效,不知jrebel保存在哪了?!但是去掉此项,又抛如下异常,只好不正常时多Synchronous module一下就好了。

2014-12-05 16:16:02 JRebel: ERROR Failed to redefine class 'com.test.chessman.User

Servlet'.: java.lang.UnsupportedOperationException: class redefinition failed: att

empted to change the schema (add/remove fields)

        at sun.instrument.InstrumentationImpl.redefineClasses0(Native Method)

        at sun.instrument.InstrumentationImpl.redefineClasses(InstrumentationImpl.

java:150)
页: [1]
查看完整版本: JRebel MAC IDEA热加载