【问题标题】:Hibernate/SQLite - Not finding org/hibernate/dialect/unique/UniqueDelegateHibernate/SQLite - 没有找到 org/hibernate/dialect/unique/UniqueDelegate
【发布时间】:2018-08-11 20:21:50
【问题描述】:

我正在尝试在 Eclipse IDE 中使用 Hibernate 和 SQLite 创建一个项目。

我的pom.xml 看起来像这样:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>xmlTesting</groupId>
  <artifactId>xmlTesting</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.3.2</version>
    </dependency>

    <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-core</artifactId>
       <version>4.1.4.Final</version>
    </dependency>

    <dependency>
        <groupId>org.xerial</groupId>
        <artifactId>sqlite-jdbc</artifactId>
        <version>3.7.2</version>
    </dependency>

    <dependency>
        <groupId>com.enigmabridge</groupId>
        <artifactId>hibernate4-sqlite-dialect</artifactId>
        <version>0.1.2</version>
    </dependency>


  </dependencies>
</project>

还有文件hibernate.cfg.xml

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM 
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
   <session-factory>

      <property name="show_sql">true</property>
      <property name="format_sql">true</property>
      <property name="dialect">com.enigmabridge.hibernate.dialect.SQLiteDialect</property>
      <property name="connection.driver_class">org.sqlite.JDBC</property>
      <property name="connection.url">jdbc:sqlite:test.db</property>
      <property name="connection.username"></property>
      <property name="connection.password"></property>

      <property name="hibernate.hbm2ddl.auto">update</property>

      <mapping class="xmlTesting.models.Employee"/>
   </session-factory>
</hibernate-configuration>

但是当我尝试运行该项目时,我得到了这个错误:

java.lang.NoClassDefFoundError: org/hibernate/方言/unique/UniqueDelegate

这是有道理的,因为我在 Eclipse IDE 的 MavenDependencies 中找不到这个包 (org.hibernate.dialect.unique)。

我正在尝试遵循本教程 http://www.srccodes.com/p/article/7/Annotation-based-Hibernate-Hello-World-example-using-Maven-build-tool-and-SQLite-database 。但似乎没有人遇到过同样的问题。

【问题讨论】:

  • 您应该发布控制台日志错误。在我看来,如果您拍摄屏幕截图错误,诊断会更容易。我无法重现错误java.lang.NoClassDefFoundError: org/hibernate/dialect/unique/UniqueDelegate
  • 我可以通过更新 Hibernate 来解决这个问题。

标签: java eclipse hibernate sqlite maven


【解决方案1】:

更改您的休眠核心版本 4.3.11.Final。您当前的版本没有UniqueDelegate 类。

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.3.11.Final</version>
</dependency>

【讨论】:

    猜你喜欢
    • 2010-12-04
    • 1970-01-01
    • 2020-12-26
    • 2017-06-13
    • 1970-01-01
    • 1970-01-01
    • 2012-06-24
    • 2012-02-02
    相关资源
    最近更新 更多