Total Pageviews

Tuesday 5 July 2016

Eclipse/IntelliJ IDEA添加JRebel 6.4.6以实现Tomcat热部署

JRebel更新到了6.4.6。更新内容见:
https://zeroturnaround.com/software/jrebel/download/changelog/6-x/
JRebel 可快速实现Tomcat的热部署,最为强大的是支持Spring注解的热部署,这样就能节省大量的服务器重启时间,提高了个人开发效率。
JRebel支持Eclipse和IntelliJ IDEA,下面分别从两个IDE介绍JRebel的安装方法,如有错误或遗漏,欢迎指出。

安装方法
1.Eclipse安装JRebel
Eclipse插件在线安装地址:
http://update.zeroturnaround.com/update-site/
添加插件在线安装地址到Eclipse,然后选择安装  JRebel for Java EE,重启之后设置里会出现  Jrebel的选项,说明安装成功。
Crack:
1.使用授权服务器:Help > JRebel Activation > I already have a license > Connect to License Server
Group URL 填写:http://idea.lanyus.com/{username}  (用任意用户名替换 {username}),Email 随意。
2.手动:
打开Eclipse目录:plugins/org.zeroturnaround.eclipse.embedder_*
分别替换 jrebel,jr6/jrebel 文件夹里的jar文件为破解后的jar文件,将证书放到用户文件夹的 .jrebel 文件夹下,例如 ~/.jrebel/。
回到Eclipse,选择Help -> JRebel Configuration 打开jrebel的配置中心,到Advance里设置JRebel agent为JRebel 6 Agent。
如果Jrebel提示没激活,请手动选择一下注册证书的路径。
设置好之后,在已有项目上右键 -> Jrebel -> Add Jrebel Nature,然后源码目录就会生成一个  rebel.xml 文件,设置成功。

2.IntelliJ IDEA安装JRebel插件:
以下步骤基于IntelliJ IDEA 16,其他版本大同小异。
File -> Settings -> Plugins -> Browse repositories...查找 JRebel for Intellij 并安装。

Crack:
1.使用第三方授权服务器:http://idea.lanyus.com/img/JRebel.png
还是那句话,如果JRebel给你节约了大量时间,而你又的确喜欢这款软件,请买正版支持一下。

2.手动:
打开插件目录:C:/Users/<当前用户>/.IntelliJIdea16/config/plugins/jr-ide-idea/lib,或者 ~/.IntelliJIdea16/config/plugins/jr-ide-idea/lib。
分别替换 jrebel 和 jrebel6 里边的jar文件为破解后的jar文件,并将注册证书放到 C:/Users/<当前用户>/.jrebel/ 文件夹下,或者 ~/.jrebel/。
回到IntelliJ IDEA:File -> Settings -> JRebel,确认一下注册状态,然后到 Advanced 选择JRebel 6 Agent。
使用方法:
在当前项目上右键 -> JRebel -> rebel.xml 来生成 rebel.xml 文件,或者在IntelliJ左下角,选择JRebel选项卡,将第一个勾上即可。(不做这步也可以)
Eclipse/IntelliJ IDEA添加JRebel 6.4.6以实现Tomcat热部署 - 第1张  | 扩软博客
Run -> Edit Configurations...,设置On ‘Update action’ 和 On firame deactivation。
Eclipse/IntelliJ IDEA添加JRebel 6.4.6以实现Tomcat热部署 - 第2张  | 扩软博客
PS:官方文档里边给出的是分别设置为“Restart server”和“Do nothing”,但是需要手动编译才能自动部署。我推荐设置为如下图,当IDEA失去焦点的时候会自动编译并重新部署,更方便。
IntelliJ安装JRebel官方教程:
http://manuals.zeroturnaround.com/jrebel/ide/intellij.html

3.JRebel使用说明
项目下的src/rebel.xml文件配置的是JRebel的监控路径,如果使用不正常,请确认一下这个文件里边配置的路径是否正确。
启动项目,如果提示类似以下信息,说明JRebel运行正常:
2015-11-25 09:00:18 JRebel:  #############################################################
2015-11-25 09:00:18 JRebel:
2015-11-25 09:00:18 JRebel:  JRebel Agent 6.2.7 (201511061217)
2015-11-25 09:00:18 JRebel:  (c) Copyright ZeroTurnaround AS, Estonia, Tartu.
2015-11-25 09:00:18 JRebel:
2015-11-25 09:00:18 JRebel:  Over the last 1 days JRebel prevented
2015-11-25 09:00:18 JRebel:  at least 0 redeploys/restarts saving you about 0 hours.
2015-11-25 09:00:18 JRebel:
2015-11-25 09:00:18 JRebel:  Licensed to VIMACER (ZeroTurnaround)
2015-11-25 09:00:18 JRebel:   with the following restrictions:
2015-11-25 09:00:18 JRebel:   ### Hello World Cracked ### :)
2015-11-25 09:00:18 JRebel:
2015-11-25 09:00:18 JRebel:  License type: enterprise
2015-11-25 09:00:18 JRebel:  Valid from: July 14, 2014
2015-11-25 09:00:18 JRebel:  Valid until: August 18, 2888
2015-11-25 09:00:18 JRebel:
2015-11-25 09:00:18 JRebel:
2015-11-25 09:00:18 JRebel:

JRebel免安装版本下载地址,不是IDE插件,可直接挂载到Tomcat:
https://zeroturnaround.com/software/jrebel/download/thank-you/?file=jrebel-6.4.6-nosetup.zip

补充一点,对于eclipse配置jrebel,还需要设置下jrebel.lic,点Help->JRebel Activation,然后选择jrebel.lic的目录.