【发布时间】:2014-04-25 13:16:50
【问题描述】:
这是我的代码。当我一次执行时,它会给出以下错误。 初始 SessionFactory 创建 failed.org.hibernate.HibernateException:未找到方言类:org.hibernate.dialect.MySQL5InnoDBDialectt
package com.bis.stock;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateUtil {
private static SessionFactory sessionFactory = buildSessionFactory();
private static SessionFactory buildSessionFactory() {
try {
//Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().configure("hibernate/Hibernate.cfg.xml").buildSessionFactory();
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;
}
}
【问题讨论】:
-
不确定是否是您的拼写错误,但您在
MySQL5InnoDBDialectt末尾有一个额外的t -
确保
org.hibernate.dialect.MySQL5InnoDBDialect 存在于您的 Hibernate.cfg.xml 文件中。还要检查@peeskillet 提到的错字。