簡體   English   中英

IntelliJ IDEA和JRebel不會重新加載類

[英]IntelliJ IDEA & JRebel doesn't reload class

我嘗試通過結構項目在簡單的IDEA中使用JRebel插件:

Test/
├── out
│   └── production
│       └── Test
│           ├── App.class
│           └── rebel.xml
├── src
│   ├── App.java
│   └── rebel.xml
└── Test.iml

rebel.xml:

<?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運行:

public class App {
    public static void main(String[] args) throws Exception {
        for (; ;) {
            System.out.println("Hello jrebel");
            Thread.sleep(1000);
        }
    }
}

JRebel日志:

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
...

當我在jrebel輸出流中更改java Word時

 System.out.println("Hello jrebel");

JRebel不會重新加載更改。

怎么了 ?

在您的示例中,執行永遠不會超出while循環,因此它永遠不會超出方法。 一個方法不能在其執行過程中被替換,因此要重新加載該方法,應首先退出該方法。

做這個:

  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循環中進行任何更改-可以重新加載該類,但該方法永遠不會退出,因此永遠不會有執行新指令的機會。

順便說一句,不要忘記編譯更改的類。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM