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;
}
}