您的位置:首页 > 其它

jrebel热部署

2017-04-18 15:54 183 查看

简介

  JavaRebel是一个工具,主要是用于热加载,比如说在Tomcat之类的应用服务器中,更新了class或者某些资源文件,使用了JRebel之后,就不需要重新启动应用服务器。这里有一点先声明一下,本文只是破解仅限于学习和研究使用,勿用于其他用途。

下载地址:http://www.zeroturnaround.com/jrebel/download/ 下载下来的是一个Zip压缩包,打开之后会发现一个jrebel.jar,这就是其最重要的运行包了。其他都是一些文档和插件。

PS. rebel出了免费社区版,参见:
http://zeroturnaround.com/blog/free-version-of-jrebel-social/

一、安装包准备

1. Jrebel.jar 核心JAR包,http://zeroturnaround.com/jrebel/prev-releases/ 上面进行下载。

安装 JRebel Eclipse插件进入 Help » Install New Software... 并且输入下面的URL :http://www.zeroturnaround.com/update-site/

2. 在eclipse marketplace中搜索jrebel也可以下载。如下图:



二、配置Eclipse

(1)、Eclipse中配置 window->preference->tomcat->JVM Settings,加入以下参数

-Drebel.spring_plugin=true 支持spring框架

-Drebel.aspectj_plugin=true 支持aspectj

-Drebel.struts2_plugin=true 支持strut2

-javaagent:D:/jrebel.jar 这里自行修改jrebel.jar正确的路径

-Drebel.dirs=F:/Project/test/WebContent/WEB-INF/classes,F:/Project/test/WebContent

-Dmyproject.root=D:/project/operamasks/workspaces/xxxx -Drebel.disable_update=true

-noverify

[(-javaagent 下载的jrebel.jar的路径,-Drebel.dirsc 项目的class文件的路径, -Dmyproject.root的值表示当前的需要热部署的工程路径)]

三、安装Eclipse插件

安装JRebel Eclipse 插件

Help » Install New Software

然后通过 如下 URL :http://www.zeroturnaround.com/update-site/

如果要离线下载的话,可以通过下载离线包的方式进行:http://www.zeroturnaround.com/update-site/update-site.zip

/**************************************************

jrebel 下载:

官网地址:http://www.zeroturnaround.com/jrebel/ (试用30天)

破解地址:http://dl.dbank.com/c086engzbb

**************************************************/

--------------------------------------------------------------



四、配置完上面后,还需要关闭tomcat的应用程序的reloadable设置

<Context path="/hello" reloadable="false
" docBase="D:/project" />

JReble log

如果你想选中Enable debug logging ,需要配置日志信息。点击Lauch JRebel Agent Settings ,可以选中Show JRebel message in standard output(在控制台输出打印),并且Log to file并且输出到日志文件中。 如果不设置日志路径,则可能会提示找不到日志的信息。点击Open JRebel agent,查看jrebel.properties,jrebel.info目录。

参考

【http://zeroturnaround.com/software/jrebel/learn/eclipse-jrebel-tutorial/】

【https://zeroturnaround.com/software/jrebel/download/installing-jrebel-plugin-for-eclipse/】

【http://manuals.zeroturnaround.com/jrebel/】

有更加好的破解

【http://blog.csdn.net/sensisoft/article/details/20010615】

破解jrebel方法

【http://www.blogjava.net/usherlight/archive/2009/10/15/298449.html】

【http://www.sdandroid.com/2014/02/jrebel_6430.html】

1. 配置tomcat服务器:修改tomcat的部署配置为:从不自动发布,禁用Web模块的自动从新装入为:禁用
2. 在tomcat运行配置上添加vm参数:-noverify -javaagent:D:\RUNTIME\jrebel\jrebel.jar -Dmyproject.root=D:/project/operamasks/workspaces/xxxx -Drebel.disable_update=true
其中:-javaagent的值表示jrebel的jar包路径
-Dmyproject.root的值表示当前的需要热部署的工程路径
3. 在工程的src源文件夹下添加名称为:rebel.xml的配置文件,内容格式如下:

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>

<dir name="${myproject.root}/bin">

</dir>

<dir name="${myproject.root}/web/WebContent/WEB-INF/classes">

</dir>

</classpath>

<web>

<link target="/">

<dir name="${myproject.root}/web/WebContent">

</dir>

</link>

</web>

</application>

其中:myproject.root就是tomcat vm参数中指定的工程路径,你也可以使用绝对路径
这个文件定义的就是jrebel要监控的具体文件夹,即class文件和资源文件(比如:jsp等)

4.最后,启动tomcat服务器的成功提示:

Fri Oct 19 10:34:29 CST 2012 com.zeroturnaround.javarebel.hD#new V( false )
Fri Oct 19 10:34:29 CST 2012 com.zeroturnaround.javarebel.bH#public boolean a(byte abyte0[])

#############################################################

JRebel 3.0-M1 (200910151623)
(c) Copyright ZeroTurnaround, Ltd, 2007-2009. All rights reserved.

A rough estimate: Over the last 5 days JRebel
prevented the need for at least 36 redeploys/restarts.
Using industry standard build and redeploy times,
JRebel saved you between 1 and 2 hours.

This product is licensed to Java Hack Organization
for unlimited number of developer seats on site.

#############################################################

JRebel: A newer version '5.0.1' is available for download
JRebel: from http://www.zeroturnaround.com/download.

2012-10-19 10:34:29 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\RUNTIME\java\jdk1.6.0_11\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:/RUNTIME/java/jdk1.6.0_11/bin/../jre/bin/client;D:/RUNTIME/java/jdk1.6.0_11/bin/../jre/bin;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;D:\RUNTIME\java\jdk1.6.0_11\bin;D:\RUNTIME\java\jdk1.6.0_11\jre\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;D:\RUNTIME\MySQL\MySQL Server 7.0\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\MacType;C:\PROGRA~1\DISKEE~1\DISKEE~1\;d:\Program Files (x86)\DBank\ClickUp;C:\Program Files (x86)\DBank\ClickUp
2012-10-19 10:34:29 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:XXX' did not find a matching property.
2012-10-19 10:34:29 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2012-10-19 10:34:29 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 324 ms
2012-10-19 10:34:29 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2012-10-19 10:34:29 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.35
JRebel: Directory 'D:\project\eclipse\workspaces\XXX\bin' will be monitored for changes.
JRebel: Directory 'D:\project\eclipse\workspaces\XXX\web\WebContent\WEB-INF\classes' will be monitored for changes.
JRebel: Directory 'D:\project\eclipse\workspaces\XXX\web\WebContent' will be monitored for changes.

=============================== [JRebel Spring Framework Plugin] ===============================
Plugins are contributed by third party and can cause compatibility problems.
If you have any troubles set -Drebel.spring_plugin=false to disable it.
------------------------------------------------------------------------------------------
Description: Supports adding new beans and adding new bean dependencies using
annotations or XML. Singletons will be reconfigured after the change. It also
supports adding or changing Spring MVC controllers or handlers.
=============================== [/JRebel Spring Framework Plugin] ==============================

=============================== [JRebel AspectJ Plugin DISABLED] ==============================
You can enable AspectJ Plugin by setting -Drebel.aspectj_plugin=true.
------------------------------------------------------------------------------------------
Description: Allows the AspectJ load-time weaving (javaagent launched by aj5 or
-javaagent:aspectjweaver.jar) to be used with JavaRebel. Note that AspectJ
weaver will still show "java.lang.Exception: AspectJ5 does not weave hotswapped
class" in the beginning, but this can be safely ignored.
=============================== [/JRebel AspectJ Plugin DISABLED] =============================

2012-10-19 10:34:30 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
JavaRebel-Spring: Monitoring Spring bean definitions in 'D:\project\eclipse\workspaces\XXX\web\WebContent\WEB-INF\applicationContext.xml'.
JavaRebel-Spring: Monitoring Spring bean definitions in 'D:\project\eclipse\workspaces\XXX\web\WebContent\WEB-INF\classes\applicationContext.xml'.
JavaRebel-Spring: Monitoring Spring bean definitions in 'D:\project\eclipse\workspaces\XXX\web\WebContent\WEB-INF\classes\applicationContext-dao.xml'.
JavaRebel-Spring: Monitoring Spring bean definitions in 'D:\project\eclipse\workspaces\XXX\web\WebContent\WEB-INF\classes\applicationContext-service.xml'.
JavaRebel-Spring: Monitoring Spring bean definitions in 'D:\project\eclipse\workspaces\XXX\bin\applicationContext-service-log.xml'.
...

到此为止,你成功配置jrebel了。

值得注意的是:
JRebel: Directory 'D:\project\eclipse\workspaces\XXX\bin' will be monitored for changes.
JRebel: Directory 'D:\project\eclipse\workspaces\XXX\web\WebContent\WEB-INF\classes' will be monitored for changes.
JRebel: Directory 'D:\project\eclipse\workspaces\XXX\web\WebContent' will be monitored for changes.

JavaRebel-Spring: Monitoring Spring bean definitions in 'D:\project\eclipse\workspaces\XXX\web\WebContent\WEB-INF\applicationContext.xml'.
JavaRebel-Spring: Monitoring Spring bean definitions in 'D:\project\eclipse\workspaces\XXX\web\WebContent\WEB-INF\classes\applicationContext.xml'.
JavaRebel-Spring: Monitoring Spring bean definitions in 'D:\project\eclipse\workspaces\XXX\web\WebContent\WEB-INF\classes\applicationContext-dao.xml'.
JavaRebel-Spring: Monitoring Spring bean definitions in 'D:\project\eclipse\workspaces\XXX\web\WebContent\WEB-INF\classes\applicationContext-service.xml'.
JavaRebel-Spring: Monitoring Spring bean definitions in 'D:\project\eclipse\workspaces\XXX\bin\applicationContext-service-log.xml'.

表示在运行期间jrebel会监控这些位置的class文件和资源文件的变化情况!!!!
以后就不需要经常启动tomcat来测试了,这种方便时可想而知的!

参考

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: