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