JRebel简介
时间: 作者:谢非
JRebel是什么?
JRebel是一套JavaEE开发工具,可快速实现热部署;
名词解释
- 热部署:就是在应用正在运行的时候升级软件,却不需要重新启动应用, 热部署一般整个内存会清空,重新加载,有可能会造成sessin丢失等环境。
- 热加载:容器状况在运行时重新加载转变编译后的类。在这类环境下内存不会清空,sessin不会丢失,但容易造成内存溢出,或者找不到方法。(最好是在调试过程中使用)
JRebel产生原因
- tomcat对热布署的支持不够全面,致使开发人员浪费大量时间在重起服务上;
- Tomcat对热布署的使用场景是Servlet+JSP+JaveBean。如果项目含有其他框架时,其热布署效果就会大大降低;
- JRebel对热布署的支持相对比较全面
- JRebel实际上支持非常多中间件,除了Tomcat还包括Jetty、Resin、Weblogic等;
- JRebel最大的提升是对java类修改时,热布署效率提高;
JRebel使用简介
- 下载jrebel.jar
- Eclipse window->preference->tomcat->JVM Settings,
- 加入以下参数 -Drebel.spring_plugin=true 支持spring框架
- Drebel.struts2_plugin=true 支持strut2
- 更多框架支持:http://www.zeroturnaround.com/jrebel/features/frameworks/
- 加入配置文件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/alderaan/rebel-2_0.xsd"> <classpath> <dirname="E:\projects\cmac\target\classes"/> <dirname="E:\projects\cmac\target\test-classes"/> </classpath> <web> <link target="/"> <dirname="E:\projects\cmac\src\main\webapp"/> </link> </web> </application>
更多配置信息:http://www.zeroturnaround.com/jrebel/configuration/
JRebel支持jetty示例
安装eclipse的jrebel插件
Help » Install New Software
然后通过 如下 URL http://www.zeroturnaround.com/update-site/
如果要离线下载的话,可以通过下载离线包的方式进行 http://www.zeroturnaround.com/update-site/update-site.zip下载jrebel5破解版
下载jrebel5破解版以后解压到D盘根目录即可
下载地址 :http://download.csdn.net/detail/lushengdi/5080360
配置jrebel破解版JAR包的路径 :d:/jrebel/jrebel.jar配置jetty实现热部署
这是为jetty加载jrebel的关键。
项目右键 》 run as 》 run configuation.. 》 点击jetty项目
在mvn jetty:run的JRE管理选项卡中的VM参数中加入
-noverify -javaagent:d:/jrebel/jrebel.jar
详细设置: http://blog.csdn.net/wxwzy738/article/details/16856665