简体   繁体   English

JPA应用程序在哪里放置META-INF文件夹

[英]Where to put META-INF folder for JPA application

The title pretty much sums it up, where would I put the META-INF directory, this is the directory that needs to include the persistence.xml file. 标题几乎总结了一下,我将把META-INF目录放在哪里,这是需要包含persistence.xml文件的目录。 My first guess is in the root of my application as a sibling folder of "Source Packages". 我的第一个猜测是在我的应用程序的根目录下,是“ Source Packages”的同级文件夹。 Thanks in advance! 提前致谢! PS - Using a Maven project structure... PS-使用Maven项目结构...

Screenshot of my current setup: 我当前设置的屏幕截图:

在此处输入图片说明

需要将META-INF文件夹放在类路径的根目录下,这可以通过将其作为源文件夹的直接子目录来实现。

It depends on where your managed classes are. 这取决于托管类的位置。 In an EAR, you would probably put it into the root of the domain JAR. 在EAR中,您可能会将其放入域JAR的根目录中。 In a web application (WAR), a common location is the WEB-INF/classes folder, so your final structure would look like this: 在Web应用程序(WAR)中,一个公共位置是WEB-INF/classes文件夹,因此您的最终结构将如下所示:

WEB-INF/classes/META-INF/persistence.xml

This is convenient, since all your classes would be processed by the persistence provider. 这很方便,因为所有类都将由持久性提供程序处理。

Is your projected structured as shown on Introduction to the Standard Directory Layout 您的投影结构是否如“标准目录布局简介”中所示

Configuration files (like hibernate.xml) should be placed in /src/main/resources In the "packaging" stage of maven, the files will automatically be placed in the correct META-INF directory 配置文件(例如hibernate.xml)应放置在/ src / main / resources中。在maven的“打包”阶段,文件将自动放置在正确的META-INF目录中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM