1.我為什么用JRebel ? Becuase Spring-Loaded 1.2.3 can't reload classes packaged in JAR files. This is coming in the next release, 1.2.4. 即Spring-Loaded 1.2.3不支持reload jar,而這個(gè)特性是我最關(guān)心的2.JRebel在eclipse reload class的話和spring-loaded基本一致,可參考我寫的這篇文章:http://www.aygfsteel.com/landon/archive/2015/06/19/425797.html VmArguments: -agentpath:C:\Users\pc\Desktop\jrebel-6.2.0-crack\lib\jrebel64.dll -noverify 注:1.本人用的是6.2.0的破解版本,如何獲取該版本,我不予置評(píng)。 2.對(duì)于-javaagent模式,我本地測(cè)試并卵,所以用了-agentpath模式,測(cè)試Ok.3.如何確定JRebel啟動(dòng)成功并reload了classes 這是我在eclipse中測(cè)試的一個(gè)輸出: 六月 26, 2015 10:40:26 上午 java.util.prefs.WindowsPreferences <init> WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(
) returned error code 5. 2015-06-26 10:40:29 JRebel: 2015-06-26 10:40:29 JRebel: ############################################################# 2015-06-26 10:40:29 JRebel: 2015-06-26 10:40:29 JRebel: JRebel Agent 6.2.0 (201505201205) 2015-06-26 10:40:29 JRebel: (c) Copyright ZeroTurnaround AS, Estonia, Tartu. 2015-06-26 10:40:29 JRebel: 2015-06-26 10:40:29 JRebel: Over the last 1 days JRebel prevented 2015-06-26 10:40:29 JRebel: at least 1 redeploys/restarts saving you about 0 hours. 2015-06-26 10:40:29 JRebel: 2015-06-26 10:40:29 JRebel: Licensed to anonymous-user 2015-06-26 10:40:29 JRebel: with the following restrictions: 2015-06-26 10:40:29 JRebel: ####### Cracked by anonymous-user, For FUN! Unlimited! Enjoy! ###### 2015-06-26 10:40:29 JRebel: 2015-06-26 10:40:29 JRebel: License type: perpetual 2015-06-26 10:40:29 JRebel: 2015-06-26 10:40:29 JRebel: 2015-06-26 10:40:29 JRebel: ############################################################# 2015-06-26 10:40:29 JRebel: 2015-06-26 10:40:29 JRebel: 2015-06-26 10:40:29 JRebel: A newer version '6.2.1' is available for download 2015-06-26 10:40:29 JRebel: from http://zeroturnaround.com/software/jrebel/download/
2015-06-26 10:40:29 JRebel: reload reload reload reload reload reload reload 2015-06-26 10:40:49 JRebel: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(
) returned error code 5. reload 2015-06-26 10:40:51 JRebel: Reloading class 'com.mavsplus.example.springloaded.Reload'. load load load 4.JRebel如何reload classes in jar ? 這個(gè)是我關(guān)心的重點(diǎn),因?yàn)槲易龅氖怯螒蚍?wù)器開發(fā),線上部署的通常是一個(gè)jar,然后指定jvm參數(shù),腳本啟動(dòng)。如線上可以分為一個(gè)mainLaunch.jar,一個(gè)reloadLogic.jar,后者jar為可reload的邏輯代碼。那么問(wèn)題就是線上如果需要更新reloadLogic.jar,怎么辦?用JRebel. 1. startup.bat 啟動(dòng)腳本(脫離eclipse)@echo off
cd /d %~dp0
java -Drebel.dirs=E:\mavsplus\reload\classes
-Drebel.log=true
-agentpath:C:\Users\pc\Desktop\jrebel-6.2.0-crack\lib\jrebel64.dll
-noverify
-cp mainLaunch.jar;reloadLogic.jar com.mavsplus.example.jrebel.JRebelExample
-Drebel.dirs用來(lái)指定Jrebel監(jiān)視reloadLogic.jar的class變化,即如果我們線上想更新reloadLogic.jar時(shí),可以打包新的reloadLogic.jar->上傳到該目錄->解壓->classes至該目錄 -->該目錄發(fā)生變化,則線上reloadLogic.jar的業(yè)務(wù)也會(huì)馬上變化5.JRebel是否可用于線上生產(chǎn)環(huán)境? 1.引用JRebelWhitePaper2014.pdf的一段話: JRebel is a –javaagent plugin for the JVM. It's a downloadable .jar file, available as a standalone .zip distribution or as an IDE plugin for Eclipse, IntelliJ IDEA or NetBeans IDE. 【JRebel will cause around 10-15% performance overhead, however during development this is more or less unnoticeable, unlike in the production environment.】 即JRebel會(huì)有很大的性能損失,所以不建議生產(chǎn)環(huán)境使用,只建議開發(fā)環(huán)境,方便部署和調(diào)試。 2.那么我就想用JRebel在線上生產(chǎn)環(huán)境怎么辦? zeroturnaround公司之前還有一個(gè)產(chǎn)品叫做liverebel,可用于線上環(huán)境。但是由于未能引起足夠的消費(fèi)者關(guān)注,所以在2014年11月也停止了。。。 3.其實(shí)JRebel和Spring-Loaded就是一個(gè)開發(fā)環(huán)境下的利器,skip build and redeploy process,大大提升了工作效率!而非生產(chǎn)環(huán)境的利器。。。因?yàn)榫€上reload本來(lái)風(fēng)險(xiǎn)就很大。6. 其他相關(guān) 1. https://docs.oracle.com/javase/8/docs/technotes/guides/jpda/ 2. https://wikis.oracle.com/display/mlvm/HotSwap 3. http://www.hotswapagent.org/ 4. https://github.com/dcevm/dcevm7.后續(xù) 我會(huì)繼續(xù)研究Java的HotSwap/HotDeploy/HotReplace/OSGI等
posted on 2015-06-26 18:48
landon 閱讀(4672)
評(píng)論(0) 編輯 收藏 所屬分類:
JVM 、
HotSwap