在将我的jpa项目部署到wildfly服务器时,我收到了警告:
The collection of metamodel types is empty.
Model classes may not have been found during entity
search for Java SE and some Java EE container managed persistence units.
Please verify that your entity classes are referenced in persistence.xml using
either <class> elements or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element
我的持久性xml看起来像这样
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="2.1">
<persistence-unit name="primary" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:jboss/datasources/example</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="javax.persistence.schema-generation.create-source" value="metadata"/>
<property name="javax.persistence.schema-generation.drop-source" value="metadata"/>
<property name="eclipselink.target-server" value="JBoss"/>
<property name="eclipselink.weaving" value="static"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/example"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="xxx"/>
</properties>
</persistence-unit>
</persistence>
我的数据库表因此没有创建。
请帮我理解这个问题。因为我无法理解其根本原因。
答案 0 :(得分:0)
对于像我一样遇到此问题的人:运行JPA工具>从实体生成表时,我刚刚在Eclipse 2020-06中遇到了此问题,尽管这种情况与问题中的情况可能有所不同并带有完全相同的错误消息。
事实证明,解决该问题的唯一方法是单击Project> Clean,然后在列表中选择JPA项目。 由于某些未知原因,在运行Generate Tables命令之间必须清理项目。我不知道为什么,但是那是事实。 HTH