gpt4 book ai didi

java - jpa,尝试从实体创建表,找不到类 ExpressionVisitor

转载 作者:行者123 更新时间:2023-12-01 10:54:54 26 4
gpt4 key购买 nike

我在 Eclipse 中从实体创建表时遇到一些麻烦。这个项目最初是在 Windows 上的 Eclipse 上,我从 mysql 表创建了实体并将其导入到项目中。一切都运转良好。昨天我决定从 Windows 切换到 ubuntu,因此我只是备份了 Eclipse 项目,认为无论如何我都可以从实体创建表。

因此,当我右键单击项目 -> JPA 工具 -> 从实体创建表时,

我收到以下错误:

Exception in thread "main" Local Exception Stack: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.6.0.v20140809-296a69f): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: org.eclipse.persistence.dynamic.DynamicClassLoader@6eceb130 Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.6.0.v20140809-296a69f): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Predeployment of PersistenceUnit [my-pu] failed. Internal Exception: java.lang.NoClassDefFoundError: org/eclipse/persistence/jpa/jpql/parser/ExpressionVisitor at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:107) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:179) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55) at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.buildEntityManagerFactory(Main.java:94) at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:80) at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:68) Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.6.0.v20140809-296a69f): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Predeployment of PersistenceUnit [my-pu] failed. Internal Exception: java.lang.NoClassDefFoundError: org/eclipse/persistence/jpa/jpql/parser/ExpressionVisitor at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1973) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1964) at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:96) ... 5 more Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.6.0.v20140809-296a69f): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Predeployment of PersistenceUnit [my-pu] failed. Internal Exception: java.lang.NoClassDefFoundError: org/eclipse/persistence/jpa/jpql/parser/ExpressionVisitor at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:231) ... 9 more Caused by: java.lang.NoClassDefFoundError: org/eclipse/persistence/jpa/jpql/parser/ExpressionVisitor at org.eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata.addJPAQuery(NamedQueryMetadata.java:105) at org.eclipse.persistence.internal.jpa.metadata.queries.NamedQueryMetadata.process(NamedQueryMetadata.java:192) at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processQueries(MetadataProject.java:1630) at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.addNamedQueries(MetadataProcessor.java:148) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1915) ... 7 more Caused by: java.lang.ClassNotFoundException: org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 12 more

Wildfly 默认使用 hibernate 作为 JPA 提供程序,我确实将其切换到 EclipseLink。

最佳答案

我在属性->jpa中将目标库更改为用户定义的库。

然后我就跟着这样说:https://www.youtube.com/watch?v=wjCCQSJVtVQ

基本上:

<persistence-unit name="my-pu" transaction-type="RESOURCE_LOCAL">
<jta-data-source>java:/forumcsDS</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>

<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/forumcs"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="X"/>
<property name="eclipseLink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipseLink.ddl-generation.output-mode" value="database"/>

</properties>
</persistence-unit>

然后我切换回旧的 persistence.xml

关于java - jpa,尝试从实体创建表,找不到类 ExpressionVisitor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33661711/

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