我只是“发现”我们有两个Meta-Inf文件夹...在Eclipse中以及在War文件中。
第一个是(在 war 中):
/META-INF/
第二,奇怪的一个原则:
/WEB-INF/classes/META-INF/
在第二个文件夹中是一个persistance.xml和一个something.taglib.xml ...
如果我将文件移到第一个meta-inf文件夹,我会从休眠中获取异常。
这个奇怪的第二个meta-inf文件夹的用途是什么?
这是正常的文件夹结构吗?
最佳答案
“怪异的”位置是正确的; JSR-220/JSR-317(Java Persistence API 1.0/2.0)在6.2/8.2节中说:
The jar file or directory whose META-INF directory contains the persistence.xml file is termed the root of the persistence unit. In Java EE, the root of a persistence unit may be one of the following:
- an EJB-JAR file
- the WEB-INF/classes directory of a WAR file
- a jar file in the WEB-INF/lib directory of a WAR file
- a jar file in the root of the EAR*
- a jar file in the EAR library directory
- an application client jar file.
*)仅对JPA 1.0有效
因此,直接在WAR文件中为,唯一正确的位置是
WEB-INF/classes/META-INF/
。
关于jakarta-ee - 两个Meta-Inf文件夹-正常结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13238615/