首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IntelliJ IDEA & JRebel不重新加载类

IntelliJ IDEA & JRebel不重新加载类
EN

Stack Overflow用户
提问于 2014-02-25 15:54:56
回答 1查看 2.1K关注 0票数 2

我尝试使用JRebel插件在简单的结构项目中使用IDEA:

代码语言:javascript
复制
Test/
├── out
│   └── production
│       └── Test
│           ├── App.class
│           └── rebel.xml
├── src
│   ├── App.java
│   └── rebel.xml
└── Test.iml

rebel.xml:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd">

    <classpath>
        <dir name="/home/ant/Documents/Java_Projects/Test/out/production/Test">
        </dir>
    </classpath>

</application>

使用JRebel -> App.java运行:

代码语言:javascript
复制
public class App {
    public static void main(String[] args) throws Exception {
        for (; ;) {
            System.out.println("Hello jrebel");
            Thread.sleep(1000);
        }
    }
}

JRebel日志:

代码语言:javascript
复制
2014-02-25 17:46:55 JRebel: 
2014-02-25 17:46:55 JRebel: #############################################################
2014-02-25 17:46:55 JRebel: 
2014-02-25 17:46:55 JRebel:  JRebel 5.5 (201312230953)
2014-02-25 17:46:55 JRebel:  (c) Copyright ZeroTurnaround OU, Estonia, Tartu.
2014-02-25 17:46:55 JRebel: 
2014-02-25 17:46:55 JRebel:  Over the last 1 days JRebel prevented 
2014-02-25 17:46:55 JRebel:  at least 0 redeploys/restarts saving you about 0 hours.
2014-02-25 17:46:55 JRebel: 
2014-02-25 17:46:55 JRebel:  You are running with an evaluation license.
2014-02-25 17:46:55 JRebel:  You have 11 days until the license expires. 
2014-02-25 17:46:55 JRebel: 
2014-02-25 17:46:55 JRebel:  You will see this notification until you obtain a 
2014-02-25 17:46:55 JRebel:  full license for your installation. 
2014-02-25 17:46:55 JRebel: 
2014-02-25 17:46:55 JRebel:  Visit www.jrebel.com for instructions on obtaining    
2014-02-25 17:46:55 JRebel:  a full license. If you wish to continue your evaluation  
2014-02-25 17:46:55 JRebel:  please e-mail to support@zeroturnaround.com.             
2014-02-25 17:46:55 JRebel:                                                           
2014-02-25 17:46:55 JRebel:  If you think you should not see this message contact     
2014-02-25 17:46:55 JRebel:  support@zeroturnaround.com or check that you have your   
2014-02-25 17:46:55 JRebel:  license file in the same directory as the JAR file.      
2014-02-25 17:46:55 JRebel: 
2014-02-25 17:46:55 JRebel:  The following plugins are disabled at the moment: 
2014-02-25 17:46:55 JRebel:  * Axis2 plugin (set -Drebel.axis2_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * Camel plugin (set -Drebel.camel_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * Click plugin (set -Drebel.click_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * Deltaspike plugin (set -Drebel.deltaspike_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * Eclipse RCP Plugin (set -Drebel.eclipse_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * JBoss7 EJB Plugin (set -Drebel.jboss7_ejb_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * JRuby Plugin (set -Drebel.jruby_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * Jersey plugin (set -Drebel.jersey_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * Log4j2 plugin (set -Drebel.log4j2_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * Mustache Plugin (set -Drebel.mustache_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * RESTlet plugin (set -Drebel.restlet_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * Seam-Wicket plugin (set -Drebel.seam_wicket_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * Spring Data Plugin (set -Drebel.spring_data_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * Thymeleaf Plugin (set -Drebel.thymeleaf_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * VRaptor plugin (set -Drebel.vraptor_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * Vaadin CDI utils plugin (set -Drebel.vaadin_cdiutils_plugin=true to enable)
2014-02-25 17:46:55 JRebel:  * WebObjects plugin (set -Drebel.webobjects_plugin=true to enable)
2014-02-25 17:46:55 JRebel: 
2014-02-25 17:46:55 JRebel: #############################################################
2014-02-25 17:46:55 JRebel: 
2014-02-25 17:46:55 JRebel: Directory '/home/ant/Documents/Java_Projects/Test/out/production/Test' will be monitored for changes.
Hello java
Hello java
Hello java
...

当我在java上更改输出流中的jrebel字时

代码语言:javascript
复制
 System.out.println("Hello jrebel");

JRebel不重新加载更改。

怎么了?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-25 16:46:01

在您的示例中,执行从不脱离while循环,因此它从未脱离该方法。方法在其执行过程中不能被替换,因此要重新加载该方法,首先要执行该方法。

这样做:

代码语言:javascript
复制
  public class App {
    public static void main(String[] args) throws Exception {
      Bean bean = new Bean();
      for (; ;) {
        bean.foo();
        Thread.sleep(1000);
      }
    }
  }

 public class Bean {
   public void foo(){
     System.out.println("Hello jrebel");
   }
 }

现在,您可以在Bean类中更改任何内容,但不能在while循环中更改--类可以重新加载,但是方法永远不会退出,因此永远不会有机会执行新的指令。

顺便说一句,不要忘记编译修改过的类。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22019451

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档