使用JavaRebel实现即时重载java class更改
本文以javarebel-2.0 free版本为例,包括如何配置在使用Eclipse插件开发tomcat应用时,实现即时重载java class更改。
1. 首先下载JavaRebel, 官方下载(Free版本) , 下载后解压到本地目录,例如 D:/javarebel.jar
2. 因为JavaRebel在不同的jdk版本,配置也不同,本例以JDK5+以上版本为例
?? 在Eclipse的tomcat插件中,配置 JavaReble, 如图
?
在Jvm配置中加入下面的设置
?
接下来,可以启动Tomcat服务了,如果配置正确,启动服务后,会有以下提示
############################################################# ZeroTurnaround JavaRebel 2.0 (200903241906) (c) Copyright Webmedia, Ltd, 2007-2009. All rights reserved. You are running JavaRebel evaluation license. You have 30 days until the license expires. You will see this notification until you obtain a full license for your installation. Visit www.javarebel.com for instructions on obtaining a full license. If you wish to continue your evaluation please e-mail to support@zeroturnaround.com. If you think you should not see this message contact support@zeroturnaround.com or check that you have your license file in the same directory as the JAR file. #############################################################JavaRebel: Directory 'D:\develop\WEB-INF\classes' will be monitored for class changes.=============================== [JavaRebel 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 usingannotations or XML. Singletons will be reconfigured after the change. It alsosupports adding or changing Spring MVC controllers or handlers.=============================== [/JavaRebel Spring Framework Plugin] ==============================?
如果出上以上提示,则表示JavaRebel已经配置成功。
接下来大家可以在Eclipse中修改代码,进行编译进行测试。
如果Eclipse提示, 则直接关接不理它即可,你发现你修改后的 class文件已经被jvm加载了
?