【问题标题】:Unable to build EntityManagerFactory Mapping XML JPA无法构建 EntityManagerFactory 映射 XML JPA
【发布时间】:2013-11-12 01:04:34
【问题描述】:

每次我在Persistance.xml 中配置orm.xml 时都会得到以下信息:

E CWWJP0015E: org.hibernate.ejb.HibernatePersistence 持久性提供程序尝试为 XYZ 持久性单元创建容器实体管理器工厂时发生错误。出现以下错误:PersistenceUnit: XYZ Unable to build EntityManagerFactory

如果我从Persistance.xml 中删除条目,它可以正常工作,但是由于我没有使用 JPA 注释,因此 `Entity Manager 无法找到实体类。

【问题讨论】:

    标签: jpa


    【解决方案1】:

    Persistance.xml 重命名为persistence.xml 请注意,p 是小写字母,并且单词“persistence”不包含字母 a

    另外,请确保 persistence.xml 位于适当的位置:

    以下内容来自 JPA 规范

    A persistence.xml file defines a persistence unit. The persistence.xml file is 
    located in the META-INF directory of the root of the persistence unit. 
    The root of the persistence unit is the key here.
    

    如果您是非 Java EE 应用程序

    The jar file or directory whose META-INF directory contains the persistence.xml 
    file is termed the root of the persistence unit.
    

    如果您在 Java EE 应用程序中,则以下内容有效

    在 Java EE 环境中,持久性单元的根必须是以下之一:

    • 一个 EJB-JAR 文件

    • WAR 文件的 WEB-INF/classes 目录[80]

    • WAR 文件的WEB-INF/lib 目录下的jar 文件

    • EAR 库目录中的 jar 文件

    • 应用程序客户端 jar 文件

    【讨论】:

      猜你喜欢
      • 2013-07-28
      • 1970-01-01
      • 1970-01-01
      • 2021-06-29
      • 2013-05-31
      • 2012-06-16
      • 1970-01-01
      • 1970-01-01
      • 2019-03-27
      相关资源
      最近更新 更多