我正在嘗試使用休眠將本地?cái)?shù)據(jù)庫(kù)連接到我的應(yīng)用程序。我收到以下錯(cuò)誤:Jul 02, 2019 9:20:08 PM org.hibernate.Version logVersionINFO: HHH000412: Hibernate Core {[WORKING]}Exception in thread "main" java.lang.NoClassDefFoundError: net/bytebuddy/NamingStrategy$SuffixingRandom$BaseNameResolver at org.hibernate.orm.core@5.4.3.Final/org.hibernate.cfg.Environment.buildBytecodeProvider(Environment.java:345) at org.hibernate.orm.core@5.4.3.Final/org.hibernate.cfg.Environment.buildBytecodeProvider(Environment.java:337) at org.hibernate.orm.core@5.4.3.Final/org.hibernate.cfg.Environment.<clinit>(Environment.java:230) at org.hibernate.orm.core@5.4.3.Final/org.hibernate.boot.registry.StandardServiceRegistryBuilder.<init>(StandardServiceRegistryBuilder.java:78) at org.hibernate.orm.core@5.4.3.Final/org.hibernate.boot.registry.StandardServiceRegistryBuilder.<init>(StandardServiceRegistryBuilder.java:67) at org.hibernate.orm.core@5.4.3.Final/org.hibernate.boot.registry.StandardServiceRegistryBuilder.<init>(StandardServiceRegistryBuilder.java:58) at ProjectDBTest/ProjectDBTest2.HibernateUtil.getSessionFactory(HibernateUtil.java:28) at ProjectDBTest/ProjectDBTest2.App.main(App.java:28)Caused by: java.lang.ClassNotFoundException: net.bytebuddy.NamingStrategy$SuffixingRandom$BaseNameResolver at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 8 more任何有關(guān)如何解決此問(wèn)題的幫助將不勝感激。最初,我遇到了“java.lang.NoClassDefFoundError: java/sql/SQLException”異常,因此在將其視為 Stack Overflow 其他地方的建議解決方案后我添加了“requires java.sql”,但現(xiàn)在出現(xiàn)了上述異常。我不確定我的代碼哪里出了問(wèn)題或缺少什么。這是我的 module-info.java 文件:module ProjectDBTest { requires java.persistence; //requires lombok; requires javafx.graphics; requires org.hibernate.orm.core; requires java.naming; requires java.sql; exports ProjectDBTest2.DB;}
1 回答

三國(guó)紛爭(zhēng)
TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超7個(gè)贊
我終于設(shè)法通過(guò)更新我的 module-info.java 文件來(lái)解決這個(gè)問(wèn)題,包括:
module AlienDB {
requires static lombok;
requires java.persistence;
requires org.hibernate.orm.core;
requires java.naming;
requires java.sql;
requires com.sun.xml.bind;
requires net.bytebuddy;
opens Aliens to org.hibernate.orm.core;
exports Aliens;
}
之前我添加了 java.xml.bind,這導(dǎo)致了更多問(wèn)題。
添加回答
舉報(bào)
0/150
提交
取消