IntelliJ IDEA 14 利用JRebel实现热部署


问题

在Java Web开发中,不像PHP等方便,在更新了Java文件后,一般要手动进行Compile->Redeploy(或重启)这两个步骤,浪费不少生命--时间就是生命啊!!。特别是在开发较大应用的时候,那个心塞的...没办法既然选择了java,那就得编译。对Java那是又爱又恨啊。虽然开发久了可以稍微避免不必要的编译。但那也是在浪费生命。更换IDEA是一个不错的选择,针对修改-->编译-->刷新浏览器的漫长等待中,今天尝试了java的热部署,确实方便了很多!!

JRebel是一款Java虚拟机插件,它使得我们能在不进行重部署的情况下,即时看到代码的改变对一个应用程序带来的影响。JRebel使你能即时分别看到代码、类和资源的变化,你可以一个个地上传而不是一次性全部部署。

 

 

一、使用Intellij IDEA手动热部署

1、Run->Edit Configurations...

当修改了代码以后,编译代码(一般都设置自动编译),然后手动点击下图的Deploy All按钮,Ctrl+F9来重新编译 ,这个相比较每次都重启Tomcat已经好多了。

 

 

二、使用JRebel插件实现热部署

1、首先得安装Jrebel插件

点击Apply 然后重启启动

 

2.激活Jrebel,说道激活Jrebel,网上有很多教程的教程和下载版本,但这个激活是最方便的,https://blog.kuoruan.com/62.html,感谢高人提供的方便快捷

http://idea.lanyus.com/img/JRebel.png

 1 2016-05-09 18:13:54 JRebel: 
 2 2016-05-09 18:13:54 JRebel: A newer version '6.4.3' is available for download 
 3 2016-05-09 18:13:54 JRebel: from http://zeroturnaround.com/software/jrebel/download/
 4 2016-05-09 18:13:54 JRebel: 
 5 2016-05-09 18:13:54 JRebel: Found offline lease from local storage.. executing JRebel with offline licensing.
 6 2016-05-09 18:13:54 JRebel:  
 7 2016-05-09 18:13:54 JRebel:  #############################################################
 8 2016-05-09 18:13:54 JRebel:  
 9 2016-05-09 18:13:54 JRebel:  JRebel Agent 6.0.2 (201412191331)
10 2016-05-09 18:13:54 JRebel:  (c) Copyright ZeroTurnaround AS, Estonia, Tartu.
11 2016-05-09 18:13:54 JRebel:  
12 2016-05-09 18:13:54 JRebel:  Over the last 1 days JRebel prevented
13 2016-05-09 18:13:54 JRebel:  at least 3 redeploys/restarts saving you about 0 hours.
14 2016-05-09 18:13:54 JRebel:  
15 2016-05-09 18:13:54 JRebel:  License acquired from License Server: http://idea.lanyus.com
16 2016-05-09 18:13:54 JRebel:  
17 2016-05-09 18:13:54 JRebel:  Licensed to ilanyu.
18 2016-05-09 18:13:54 JRebel:  
19 2016-05-09 18:13:54 JRebel:  You are using an offline license.
20 2016-05-09 18:13:54 JRebel:  
21 2016-05-09 18:13:54 JRebel:  
22 2016-05-09 18:13:54 JRebel:  #############################################################
23 2016-05-09 18:13:54 JRebel:  

另附在线获取idea验证码和帮助的URL  和给力 http://idea.lanyus.com/
如果报java.lang.OutOfMemoryError: PermGen space,需设置VM options,设置“-XX:MaxPermSize=1024m -Dfile.encoding=UTF-8”,JReble无需配置就可以实现热重启,前提是需要将Tomcat的配置“On frame deactivation”从”Do nothing”改成”Update classes and resources”。

 

三、Jrebel不起作用的解决办法

有时候会发现Jrebel不起作用,即使是重启Tomcat都不起作用。
我遇到的问题原因是:
在Jrebel项目配置文件会存放项目的路径,我将项目复制了一份,项目路径变了,但是相应的配置文件中没有更改,所以,Jrebel就不起作用了。
解决办法如下:
(1)如果项目中不存在rebel.xml  在Jrebel插件中点击生成rebel.xml
(2)如果项目中已存在rebel.xml   在src/main/resources中修改项目的路径,查看项目路径是否正确!!

 

感谢:

http://www.cnblogs.com/wql025/p/5017823.html

https://blog.kuoruan.com/62.html

http://cnitzone.com/blog/2015/06/idea-hot-deploy/

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM