2013-05-10 34 views
0

我正在創建一個HibernateUtil.java類來返回SessionFactory對象。但它提供了錯誤「無法解析java.lang.Object類型,它是從所需的.class間接引用的」。我的代碼是 -創建SessionFactory對象形式時出錯hibernate.cfg.xml

import org.hibernate.SessionFactory; 
import org.hibernate.cfg.Configuration; 

public class HibernateUtil { 

private static final SessionFactory sessionFactory = buildSessionFactory(); 
@SuppressWarnings("deprecation") 
private static SessionFactory buildSessionFactory() { 
    try { 
     // Create the SessionFactory from hibernate.cfg.xml 
     return new Configuration().configure().buildSessionFactory(); 
    } catch (Throwable ex) { 
     System.err.println("Initial SessionFactory creation failed." + ex); 
     throw new ExceptionInInitializerError(ex); 
    } 
} 

public static SessionFactory getSessionFactory() { 
    return sessionFactory; 
} 
} 

回答

1

它似乎你沒有包括jre系統自由的建立路徑。

Right click on project --> Properties --> select Java Build Path --> Libraries -->  
Add Library --> JRE System Library --> Next --> Workspace default JRE --> Finish 
相關問題