我对休眠很陌生,所以我正在通过看视频教程来练习。我下面的链接是,
https://www.youtube.com/watch?v=FFMOZY4z6bE&list=PL4AFF701184976B25&index=5
这是Eclipse中的一个简单的Java项目。这里我使用MySQL数据库。这是我的Hibernate.cfg.xml文件,
驱动程序jdbc:mysql://本地主机:3306/休眠数据库根根
<!-- 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)
有人能帮我一下吗。
3条答案
按热度按时间sbdsn5lh1#
如果使用的是属性文件,请确保行尾没有空格。
vsmadaxz2#
答案就在问题中,您在jar文件中找到了
MySQLDialect
,但是您的配置文件试图使用MYSQLDialect
。尝试更改为以下
s2j5cfk03#
如果您正在使用
只需从那里删除
8