【问题标题】:Cannot resolve class dialect无法解析班级方言
【发布时间】:2019-08-07 16:43:19
【问题描述】:

我试图解决一个问题几个小时,但似乎没有任何效果。我尝试了所有在线可用的方法。我正在使用 Intellij IDEA。我正在使用一个 Maven 项目。我创建了hibernate.cfg.xml,内容如下

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>
        <property name="connection.driver_class">org.h2.Driver</property>
        <property name="connection.url">jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</property>
        <property name="dialect">org.hibernate.dialect.H2Dialect</property>
        <property name="show_sql">true</property>
        <property name="hbm2ddl.auto">create</property>
        <mapping class="User"/>
    </session-factory>
</hibernate-configuration>

以下行抛出无法解析类dialect的错误

<property name="dialect">org.hibernate.dialect.H2Dialect</property>

我的外部库结构如下所示。

任何帮助将不胜感激。

【问题讨论】:

  • 发布准确完整的异常堆栈跟踪。
  • 我不确定,但有时它会显示此错误。 File is not configured as hibernate facet
  • @QasimAli 您是否仅在 pom.xml 突出显示或应用程序运行时收到错误?
  • @CrazyCoder 仅在 hibernate.cfg.xml 突出显示时。我没有尝试运行它。

标签: java hibernate maven intellij-idea


【解决方案1】:

我解决了这个问题。问题是 Intellij IDEA 无法为 Hibernate 下载 maven 文件。我使用maven repository 来添加存储库。

【讨论】:

    猜你喜欢
    • 2017-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多