gpt4 book ai didi

java - 线程 "main"java.lang.NoClassDefFoundError :javax/persistence/Cacheable 中出现异常

转载 作者:行者123 更新时间:2023-11-30 08:12:58 24 4
gpt4 key购买 nike

我有一个简单的 java hibernate 来创建表。执行时出现异常。

public class TestEmployee {
public static void main(String[] args) {
AnnotationConfiguration config = new AnnotationConfiguration();
config.addAnnotatedClass(Employee.class);
config.configure();

new SchemaExport(config).create(true, true);
}
}

异常(exception)是:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/Cacheable
at org.hibernate.cfg.AnnotationBinder.determineCacheSettings(AnnotationBinder.java: 988)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:579)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:4035)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3989)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:1002 )
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:130)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:92)
at com.Hibernate.chapter1.TestEmployee.main(TestEmployee.java:15)
Caused by: java.lang.ClassNotFoundException: javax.persistence.Cacheable
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

最佳答案

在项目构建路径中添加hibernate-jpa-2.0-api-1.0.0.Final库。从Maven Repo下载。其他版本可用 here .

关于java - 线程 "main"java.lang.NoClassDefFoundError :javax/persistence/Cacheable 中出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30100515/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com