您的位置:首页 > 运维架构 > Tomcat

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

2016-12-19 09:54 471 查看
     http://showlike.iteye.com/blog/1680034

     你是否有过为修改后台代码,项目重部署而出现的漫长等待而烦恼,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参数,在已有参数后增加如下代码 

Java代码  


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

-noverify  

如下图: 





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





5、在需热部署的项目src目录下添加名称为rebel.xml的配置文件(可在附件中下载),内容如下: 

Java代码  


<?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>  

至此配置完成,启动项目,控制台打印如下信息未出现异常,即说明配置成功: 

Java代码  


[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等配置文件会自动热部署。 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: