Persistence.xml放在eclipse项目中

编程入门 行业动态 更新时间:2024-10-23 15:24:30
本文介绍了Persistence.xml放在eclipse项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

简单的问题... 我在Eclipse环境中有几个项目 包含的MainApp(企业应用程序项目)

Simple question... I have a few projects in Eclipse enviroment MainApp(Enterprise Application Project) which "includes"

  • WebController(EJB Project)
  • WebModel(JPA Project)
  • WebView Web项目)
  • 问题是在哪里放置persistance.xml文件?

    Problem is where to put persistance.xml file?

    获取异常: java.lang.IllegalStateException:无法检索UnitName DataModel的EntityManagerFactory

    Getting exception: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName DataModel

    推荐答案

    8.2节中的 JPA 2.0规范规定了包装的要求。它说

    The JPA 2.0 specification in section 8.2 states the requirements for packaging. It says

    持久化单元由 persistence.xml文件定义。该文件或目录,其META-INF目录包含persistence.xml文件是,称为持久性单位的根。

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

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

    In Java EE environments, the root of a persistence unit must be one of the following:

    • 一个EJB-JAR文件
    • WAR文件的WEB-INF / classes目录[80]
    • WAR文件的WEB-INF / lib目录
    • EAR库目录中的jar文件
    • 应用程序客户端jar文件
    • an EJB-JAR file
    • the WEB-INF/classes directory of a WAR file[80]
    • a jar file in the WEB-INF/lib directory of a WAR file
    • a jar file in the EAR library directory
    • an application client jar file

    不需要将包含持久性单元的EJB-JAR或 WAR文件打包在EAR中,除非持久化单元除了在EJB-JAR或WAR中包含之外,还包含持久性类。见 8.2.1.6。

    It is not required that an EJB-JAR or WAR file containing a persistence unit be packaged in an EAR unless the persistence unit contains persistence classes in addition to those contained within the EJB-JAR or WAR. See Section 8.2.1.6.

    如果您认为有必要,可以阅读本章的其余部分。在Eclipse中,这意味着您需要配置项目之间的依赖关系,以确保部署文件被正确打包。您通常在项目 - >属性 - 构建路径中配置项目选项卡。

    You can read the rest of the chapter if you deem it necessary. In Eclipse that means that you need to configure the dependencies between your projects to ensure the deployment files are packaged appropriately. You typically configure that in Project->Properties->Build Path in the Projects tab.

    但是,我不确定Eclipse是否按照Web服务器部署的要求进行打包。我知道它在EAR项目中。

    However, I am not sure if Eclipse packages it up as required for Web server deployment. I know it does in a EAR project.

    更多推荐

    Persistence.xml放在eclipse项目中

    本文发布于:2023-10-25 14:09:16,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1527185.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:放在   项目   Persistence   xml   eclipse

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!