2015-11-23 54 views
0

我正在使用Roo 1.3.2。我有一個抽象類,具體實現如下:Spring Roo在ActiveRecord.aj中爲EntityManager生成錯誤

@RooJavaBean 
@RooToString 
@RooJpaActiveRecord(inheritanceType="TABLE_PER_CLASS")  
public abstract class Task { 
     @Size(min = 2) 
     private String name; 
     public abstract void execute(Object... parameters); 
} 

@RooJavaBean 
@RooToString 
@RooJpaActiveRecord 
public class ImportLoadPlanTask extends Task { 
    @Size(min = 2) 
    private String svnFile; 

    @Override 
    public void execute(Object... parameters){ 
     .... 
    } 
} 

然而ActiveRecord.aj文件生成產生以下代碼

public static final EntityManager Task.entityManager() { 
     EntityManager em = new Task() { 
      public void execute(java.lang.Object parameters) { 
       throw new UnsupportedOperationException(); 
      } 
     }.entityManager; 
     if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); 
     return em; 
    } 

而且從IDE的錯誤消息:

The type new Task(){} must implement the inherited abstract Task.execute(Object ...) 

如果我從Task類中刪除抽象關鍵字,則錯誤消失,因爲Roo不會嘗試生成上面列出的代碼。

我該如何得到這個工作?這是一個Roo錯誤嗎?

回答

0

這是一個檢測parameters參數類型的錯誤。請,你能在Spring Roo Jira上報告嗎?

爲了解決它只是用推擠

public abstract class Task { 
    @Size(min = 2) 
    private String name; 
    public abstract void execute(Object... parameters); 

    // Push-in entityManager method from .aj file 
    public static final EntityManager entityManager() { 
     EntityManager em = new Task() { 
      public void execute(Object... parameters) { 
       throw new UnsupportedOperationException(); 
      } 
     }.entityManager; 
     if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); 
     return em; 
    } 
} 

這是Spring Roo的要點之一:你總是可以做你的方式!

祝你好運!

+0

感謝您的回覆,我會嘗試一下您的建議。我已經記錄了一個錯誤。出於興趣,你可以在這裏找到[ROO-3688](https://jira.spring.io/browse/ROO-3688?jql=project%20%3D%20ROO) – Neriyan

+0

謝謝你報告:) – jmvivo

相關問題