2

我在 Joda 时间有以下实体。

@Column(name = "CLASS_START_DT")
@Type(type = "org.joda.time.contrib.hibernate.PersistentDateTime")
private DateTime classStartDate;

@Column(name = "CLASS_END_DT")
@Type(type = "org.joda.time.contrib.hibernate.PersistentDateTime")
private DateTime classEndDate;

它编译得很好。没有问题。但是当我运行代码时,将数据插入到这个实体中时,它会抛出错误。

java.lang.NoClassDefFoundError: org/hibernate/type/StandardBasicTypes
   ...
   ..
Caused by: java.lang.ClassNotFoundException: org.hibernate.type.StandardBasicTypes
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

Pom.xml 条目:

<dependency>
   <groupId>joda-time</groupId>
   <artifactId>joda-time</artifactId>
   <version>2.2</version>
</dependency>
<dependency>
   <groupId>joda-time</groupId>
   <artifactId>joda-time-hibernate</artifactId>
   <version>1.2</version>
</dependency>

也试过1.3版本。使用休眠 3.2。

不知道我错过了什么。

4

2 回答 2

4

org.hibernate.type.StandardBasicTypes在 4.0 版之前不适用于 Hibernate。尝试升级您的 Hibernate 版本

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.0.0.Final</version>
</dependency>
于 2013-07-12T21:39:12.277 回答
2

If you want to use org.hibernate.type.StandardBasicTypes, you need a version of hibernate 3.6 (I recommend you 3.6.10) or up. With versions lower it does not found good.

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>3.6.10.Final</version>
</dependency>
于 2014-05-27T09:52:17.897 回答