2010-09-23 55 views
1

我有以下類別:無法獲取activejdbc的工作?

package models; 

public class Test extends activejdbc.Model 
{ 
} 

:和:

import activejdbc.*; 
import models.Test; 

public class ActiveJdbc 
{ 
    public static void main(String args []) throws Exception 
    { 
     System.out.println("starting..."); 
     test(); 
    } 


    public static void test() throws Exception 
    { 
     activejdbc.Base.open("org.h2.Driver", "jdbc:h2:tcp://localhost/~/test", "sa", ""); 

     models.Test t = models.Test.findFirst("id = ??",1); 
     String s = t.get("name").toString(); 
     System.out.println(s); 
    } 

} 

:但是當我運行它:

java -cp .;../lib/h2.jar;../lib/activejdbc.jar;../lib/slf4j-simple.jar;../lib/javalite.jar ActiveJdbc 

:我得到的錯誤:

starting... 
Exception in thread "main" activejdbc.DBException: failed to determine Model class name, are you sure models have been instrumented? 
     at activejdbc.Model$ClassGetter.getClassName(Model.java:1577) 
     at activejdbc.Model.getClassName(Model.java:1546) 
     at activejdbc.Model.getDaClass(Model.java:1538) 
     at activejdbc.Model.getTableName(Model.java:1550) 
     at activejdbc.Model.getMetaModel(Model.java:58) 
     at activejdbc.Model.findFirst(Model.java:1073) 
     at ActiveJdbc.test(ActiveJdbc.java:17) 
     at ActiveJdbc.main(ActiveJdbc.java:9) 
Caused by: java.lang.RuntimeException: failed to determine Model class name, are you sure models have been instrumented? 

:任何人都可以對此有所瞭解嗎?

回答

2

我自從想通了。您需要先運行:

java -DoutputDirectory =。 -cp。; activejdbc-instrumentation.jar; javassist.jar; activejdbc.jar; activejdbc.instrumentation.Main

+0

這怎麼能幫到忙? – 2014-09-08 13:11:34

+0

當時的答案是正確的。我在四年前回答過,所以在我回答你之前我必須先刷新自己。 – Zubair 2014-09-09 12:23:52