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,而這個特性是我最關心的2.JRebel在eclipse reload class的話和spring-loaded基本一致,可參考我寫的這篇文章:http://m.tkk7.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的破解版本,如何獲取該版本,我不予置評。 2.對于-javaagent模式,我本地測試并卵,所以用了-agentpath模式,測試Ok.3.如何確定JRebel啟動成功并reload了classes 這是我在eclipse中測試的一個輸出: 六月 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 ? 這個是我關心的重點,因為我做的是游戲服務器開發,線上部署的通常是一個jar,然后指定jvm參數,腳本啟動。如線上可以分為一個mainLaunch.jar,一個reloadLogic.jar,后者jar為可reload的邏輯代碼。那么問題就是線上如果需要更新reloadLogic.jar,怎么辦?用JRebel. 1. startup.bat 啟動腳本(脫離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用來指定Jrebel監視reloadLogic.jar的class變化,即如果我們線上想更新reloadLogic.jar時,可以打包新的reloadLogic.jar->上傳到該目錄->解壓->classes至該目錄 -->該目錄發生變化,則線上reloadLogic.jar的業務也會馬上變化5.JRebel是否可用于線上生產環境? 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會有很大的性能損失,所以不建議生產環境使用,只建議開發環境,方便部署和調試。 2.那么我就想用JRebel在線上生產環境怎么辦? zeroturnaround公司之前還有一個產品叫做liverebel,可用于線上環境。但是由于未能引起足夠的消費者關注,所以在2014年11月也停止了。。。 3.其實JRebel和Spring-Loaded就是一個開發環境下的利器,skip build and redeploy process,大大提升了工作效率!而非生產環境的利器。。。因為線上reload本來風險就很大。6. 其他相關 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.后續 我會繼續研究Java的HotSwap/HotDeploy/HotReplace/OSGI等
posted on 2015-06-26 18:48
landon 閱讀(4677)
評論(0) 編輯 收藏 所屬分類:
JVM 、
HotSwap