【问题标题】:Adding new class to persistence.xml throws java.lang.IllegalArgumentException: Object: Restaurants{id=null, name=Subway} is not a known entity type向 persistence.xml 添加新类会引发 java.lang.IllegalArgumentException: Object: Restaurants{id=null, name=Subway} is not a known entity type
【发布时间】:2016-01-09 02:22:59
【问题描述】:

我创建了一个新的实体类,并将其添加到persistence.xml 文件中。

<class>xxx.xxx.xxx.xxx.xxx.Restaurants</class>

尝试在 Maven 中构建时,我收到此错误:

Caused by: java.lang.IllegalArgumentException: Object: Restaurants{id=null, name=Subway} is not a known entity type.

这是如何引起的,我该如何解决?其他实体类没有问题,只有这个。

【问题讨论】:

  • 是否标注为实体?您是否使用 Maven 配置文件进行构建?
  • @hermitmaster 是的,我在课堂上添加了“实体”。我不确定您所说的“Maven 配置文件”是什么意思?请问,你能解释一下吗?
  • ´@Entity´ 但无法在上面的评论中使用 at 符号并同时标记您。
  • 在我们的一些应用程序中,我们使用 Maven 构建配置文件,这些配置文件使用不同的 persistence.xml 文件进行测试、生产等。maven.apache.org/guides/introduction/…
  • @hermitmaster 谢谢!我已将新实体类添加到“persistence.xml”文件中,但忘记将其添加到“test-persistence.xml”文件中,因此在测试时出现错误。谢谢,请用您之前评论的内容“回答我的问题”,以便我接受并获得积分。

标签: jpa entity eclipselink illegalargumentexception persistence.xml


【解决方案1】:

在我们的一些应用程序中,我们使用 Maven 构建配置文件,这些配置文件使用不同的 persistence.xml 文件进行测试、生产等。http://maven.apache.org/guides/introduction/introduction-to-profiles.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-17
    • 2021-08-04
    • 2021-02-21
    • 2018-11-16
    相关资源
    最近更新 更多