java - Hibernate/SQLite - 找不到 org/hibernate/dialect/unique/UniqueDelegate

标签 java eclipse hibernate sqlite maven

我正在尝试在 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/dialect/unique/UniqueDelegate

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

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

最佳答案

更改您的 hibernate-core 版本 4.3.11.Final。您当前的版本没有 UniqueDelegate 类。

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

关于java - Hibernate/SQLite - 找不到 org/hibernate/dialect/unique/UniqueDelegate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49089118/

相关文章:

java - 从 java 运行 Jmeter 测试时,它不使用属性

java - 正则表达式:是否可以跳过重复的负向后查找?

java - ElementNSImpl 无法在带有 Java Zulu 11 的 Eclipse 中工作

java - 对于 JPA 元模型生成的类,Maven "clean install site"失败

java - 在 Spring 表达式语言中访问属性文件

java - 在我的语法中,字符 '<EOF>' 没有可行的替代方案

java - 更新 eclipse 插件中的 IFile 内容

java - Tomcat 上下文初始化失败

java - Hibernate CRUD 类似于 Ruby on Rails 的脚手架

hibernate - 单个实体中的多个@id 注释