gpt4 book ai didi

java - Hibernate配置文件: Archive for required library persistence. xml无法读取

转载 作者:行者123 更新时间:2023-12-02 09:29:09 27 4
gpt4 key购买 nike

我尝试了在 stackoverflow 上找到的所有答案,但没有一个适合我的问题:

Archive for required library: 'src/main/resources/META-INF/persistence.xml' in project 'project' cannot be read or is not a valid ZIP file

errors

我的 hibernate 配置文件“persistence.xml”直接位于 src/main/resources 的 META-INF 文件夹中,但 Eclipse 继续告诉我存在构建路径问题。

内容如下:

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="app.shellx.jpa">
<!-- <jta-data-source>java:/DefaultDS</jta-data-source> -->
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL9Dialect"/>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
</properties>
</persistence-unit>
</persistence>

并且 persistence.xml 被显式添加到构建路径:

buildpath

此外,Eclipse 打印了很多错误弹出窗口,我无法像那样编码。

最佳答案

您不必将其添加为库,只需将其保留在资源文件夹中即可。

关于java - Hibernate配置文件: Archive for required library persistence. xml无法读取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58115331/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com