首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Jrebel 基于TOMCAT兑现项目修改热部署

2012-10-31 
Jrebel 基于TOMCAT实现项目修改热部署你是否有过为修改后台代码,项目重部署而出现的漫长等待而烦恼,JRebel

Jrebel 基于TOMCAT实现项目修改热部署
    你是否有过为修改后台代码,项目重部署而出现的漫长等待而烦恼,JRebel就是这样一套解决修改后台代码快速实现热部署的开发工具,节省了大量重启时间,提高了个人开发效率。JRebel是收费软件,用户可以在JRebel官方站点下载30天的评估版本。网上可搜索到破解版,闲话就不说了,直接进入正题。

应用环境:
     JDK: 1.6.0_26 + Tomcat6 + eclipse3.7.2 + JRebel5.0.1
系统架构
     struts2 + spring3 + ibaits2.3

配置步骤:
     1、下载JRebel工具包(本文附件),把此包放置至Tomcat lib目录下(应该可放置其他目录,大家可自已试下,后续会配置指向此路径)

     2、打开Tomcat配置页面,如下图:


     3、配置VM arguments参数,在已有参数后增加如下代码

-javaagent:E:\work\64\apache-tomcat-6.0.35\lib\jrebel.jar-noverify

如下图:



4、修改需热部署项目原有的部署参数,如下图:




5、在需热部署的项目src目录下添加名称为rebel.xml的配置文件(可在附件中下载),内容如下:
<?xml version="1.0" encoding="UTF-8"?><application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd">    <classpath>    //项目源代码class路径,有些为项目名\bin        <dir name="F:\workspace\rom\build\classes">         </dir>    </classpath>    <web>        <link target="/">            <dir name="F:\workspace\rom\WebContent">            </dir>        </link>    </web></application>


至此配置完成,启动项目,控制台打印如下信息未出现异常,即说明配置成功:
[2012-09-17 20:57:25] [2012-09-17 20:57:25] #############################################################[2012-09-17 20:57:25] [2012-09-17 20:57:25]  JRebel 5.0.0 (201206080930)[2012-09-17 20:57:25]  (c) Copyright ZeroTurnaround OU, Estonia, Tartu.[2012-09-17 20:57:25] [2012-09-17 20:57:25]  Over the last 1 days JRebel prevented [2012-09-17 20:57:25]  at least 9 redeploys/restarts saving you about 0.4 hours.[2012-09-17 20:57:25] [2012-09-17 20:57:25]  This product is licensed to Unlimited[2012-09-17 20:57:25]  For FUN! Unlimited! Enjoy![2012-09-17 20:57:25] [2012-09-17 20:57:25]  The following plugins are disabled at the moment: [2012-09-17 20:57:25]  * Apache MyFaces plugin (set -Drebel.myfaces_plugin=true to enable)[2012-09-17 20:57:25]  * Click plugin (set -Drebel.click_plugin=true to enable)[2012-09-17 20:57:25]  * JRuby Plugin (set -Drebel.jruby_plugin=true to enable)[2012-09-17 20:57:25]  * Jersey plugin (set -Drebel.jersey_plugin=true to enable)[2012-09-17 20:57:25]  * Oracle ADF Core plugin (set -Drebel.adf_core_plugin=true to enable)[2012-09-17 20:57:25]  * Oracle ADF Faces plugin (set -Drebel.adf_faces_plugin=true to enable)[2012-09-17 20:57:25]  * Seam-Wicket plugin (set -Drebel.seam_wicket_plugin=true to enable)[2012-09-17 20:57:25]  * WebObjects plugin (set -Drebel.webobjects_plugin=true to enable)[2012-09-17 20:57:25] [2012-09-17 20:57:25] #############################################################[2012-09-17 20:57:25] [2012-09-17 20:57:25] [2012-09-17 20:57:25] JRebel: A newer version '5.0.1' is available for download [2012-09-17 20:57:25] JRebel: from http://www.zeroturnaround.com/jrebel/upgrade/[2012-09-17 20:57:25] 


当修改代码保存后,控制台会打印如下信息,即说明配置已生效,不需再等待重部署就可以看到修改后的效果,是不是感觉很爽,^-^
[2012-09-17 21:04:57] JRebel: Reloading class 'com.alili.rom.action.system.admin.UserAction'.


注: 经实际项目中应用,只有当修改Spring配置文件时,才需重新部署项目,而修改struts、ibatis等配置文件会自动热部署。
1 楼 theoffspring 2012-09-17   这玩意儿不错,不过貌似social版的现在不能用了,前天开始不好用了,只好又找了个破解。不过,还不是太彻底,spring的bean修改后,含有注解的bean不会自动重新扫描,还是得重启。只能说部分解决了问题。 2 楼 fuoing 2012-09-17   如果项目有使用struts,会报错的。 3 楼 yusheng5273 2012-09-18   ???
需要用任何插件么??
eclipse 打开debug 模式,配置tomcat conf下的xml,自动就热启了,我一直在这么用。。。。
搞不懂楼主和开发这款插件的人, 4 楼 shuaiji 2012-09-18   确实好想法,开发时候可以方便测试,但是PRODUCT 上还是愿意重启。不想因为不能预知的意外带来更多的麻烦 5 楼 king520 2012-09-18   jetty+jrebel 6 楼 wancaibida 2012-09-18   用了jrebel debug断点就不怎么好用了 7 楼 theoffspring 2012-09-18   yusheng5273 写道???
需要用任何插件么??
eclipse 打开debug 模式,配置tomcat conf下的xml,自动就热启了,我一直在这么用。。。。
搞不懂楼主和开发这款插件的人,

你修改个类能热部署吗?当然如果用weblogic确实能不借助插件就热部署的。weblogic挺方便的。 8 楼 iwangxiaodong 2012-09-19   其实Tomcat热部署已经很完美了,何必自寻烦恼! 9 楼 showlike 2012-09-19   iwangxiaodong 写道其实Tomcat热部署已经很完美了,何必自寻烦恼!

jrebel 的热部署和TOMCAT不一样,简单点,如果说你是修改后台代码,而后台代码是需登陆才能操作功能的,那TOMCAT热部署的话,还需重新登陆,而jrebel就不用,而且也不用等待 10 楼 cy729215495 2012-09-19   不支持xml配置文件的修改。实际并无多大的用处 11 楼 showlike 2012-09-29   cy729215495 写道不支持xml配置文件的修改。实际并无多大的用处
经实际项目中应用,只有当修改Spring配置文件时,才需重新部署项目,而修改struts、ibatis等配置文件会自动热部署。
在实际项目开发中修改spring配置的机率占的比例应该不大

12 楼 ekisstherain 4 小时前   tomcat不能用啊
报错:

java.lang.NullPointerException
at com.sun.facelets.compiler.TagLibraryrReloader.getLastModified(TagLibraryrReloader.java:55)
at com.sun.facelets.compiler.TagLibraryrReloader.reload(TagLibraryrReloader.java:28)
at com.sun.facelets.compiler.Compiler.compile(Compiler.java)

热点排行