Hibernate / SQLite - 没有找到org / hibernate / dialect / unique / UniqueDelegate

问题描述 投票:1回答:1

我正在尝试在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中的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 eclipse hibernate sqlite maven
1个回答
1
投票

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

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.3.11.Final</version>
</dependency>
© www.soinside.com 2019 - 2024. All rights reserved.