gpt4 book ai didi

java - 使用 netbeans 使用 Restful Web 服务时,http ://xmlns. jcp.org/xml/ns/persistence":persistence-unit}' 是预期错误

转载 作者:行者123 更新时间:2023-12-02 03:28:31 25 4
gpt4 key购买 nike

我正在使用 jersey 部署一个 Restful Web 服务。我正在阅读本教程并执行说明: http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/RESTfulWebServices/RESTfulWebservices.htm

但是我在服务器上部署时遇到此错误。

Severe: Exception while deploying the app [PlayerServer2] : org.xml.sax.SAXParseException; lineNumber: 5; columnNumber: 15; Deployment descriptor file META-INF/persistence.xml in archive [classes]. cvc-complex-type.2.4.b: The content of element 'persistence' is not complete. One of '{"http://xmlns.jcp.org/xml/ns/persistence":persistence-unit}' is expected.

我使用的是 netbean 8.0.1、glassfish 服务器 4.1、JDK 1.8.91、JPA 2.1

编辑:

持久性.xml

<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="PlayerServer2PU" transaction-type="JTA">
<jta-data-source>jdbc/playerdb2</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>

最佳答案

请删除空的<properties/>标签顺序为persistence.xml文件才能正确处理。

关于java - 使用 netbeans 使用 Restful Web 服务时,http ://xmlns. jcp.org/xml/ns/persistence":persistence-unit}' 是预期错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38426317/

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