添加新的 class 到 persistence.xml 抛出 java.lang.IllegalArgumentException: Object: Restaurants{id=null, name=Subway} is not a known entity type

Adding new class to persistence.xml throws java.lang.IllegalArgumentException: Object: Restaurants{id=null, name=Subway} is not a known entity type

我创建了一个新实体 class,并将其添加到 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.

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

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