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

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

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

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

2、打开Tomcat配置页面,如下图:
[img]http://dl.iteye.com/upload/picture/pic/118351/70726373-6ccd-3f3a-92af-86c4c7515942.jpg[/img]

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

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

如下图:
[img]http://dl.iteye.com/upload/picture/pic/118353/4dcf77b6-5f36-342c-8b20-6ebef4aff2dc.jpg[/img]
[img]http://dl.iteye.com/upload/picture/pic/118357/14e117fc-126d-3b83-9bf9-9ae49213fd6d.jpg[/img]

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

[img]http://dl.iteye.com/upload/picture/pic/118363/a1457f28-ae75-3681-b67e-d00609005639.jpg[/img]
[img]http://dl.iteye.com/upload/picture/pic/118365/95378bb2-e945-3a3b-af0d-b7775501a177.jpg[/img]

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]


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


[color=red][b]注: 经实际项目中应用,只有当修改Spring配置文件时,才需重新部署项目,而修改struts、ibatis等配置文件会自动热部署。[/b][/color]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值