如何解决“找不到Dialect类:org.hibernate.dialect.MYSQLDialect";例外? [英] How to resolve "Dialect class not found: org.hibernate.dialect.MYSQLDialect" Exception?
问题描述
我刚冬眠,所以我正在看视频教程进行练习.我关注的链接是
I am very new to hibernate so I am practicing by seeing video tutorial. The link I am following is,
https://www.youtube.com/watch? v = FFMOZY4z6bE& list = PL4AFF701184976B25& index = 5
这是eclipse中的简单Java项目.在这里,我使用mysql数据库.这是我的Hibernate.cfg.xml文件,
It is simple java project in eclipse. Here I use mysql Data base. Here is my Hibernate.cfg.xml file,
com.mysql.jdbc.Driver jdbc:mysql://本地主机:3306/hibernatedb 根 根
com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/hibernatedb root root
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MYSQLDialect</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<!-- Names the annotated entity class -->
<mapping class="com.***.dto.UserDetails"/>
我遇到这种错误,
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" org.hibernate.HibernateException: Dialect class not found: org.hibernate.dialect.MYSQLDialect
at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:159)
at org.hibernate.dialect.resolver.DialectFactory.buildDialect(DialectFactory.java:99)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:117)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)
at com.aurodisplay.hibernate.HibernateTest.main(HibernateTest.java:17)
Caused by: java.lang.ClassNotFoundException: org.hibernate.dialect.MYSQLDialect
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:156)
有人可以帮我吗?
推荐答案
答案在问题中.您在jar文件中找到了MySQLDialect
,但是您的配置文件尝试使用MYSQLDialect
. Java区分大小写.
The answer is in the question. You've found MySQLDialect
in your jar files, but your configuration file tries to use MYSQLDialect
. Java is case-sensitive.
尝试更改为以下
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
这篇关于如何解决“找不到Dialect类:org.hibernate.dialect.MYSQLDialect";例外?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!