cvc-complex-type.2.4.b:元素“持久性”的内容不完整。预期为“ {{http://xmlns.jcp.org/xml/ns/persistence“ ...”之一

时间:2018-10-14 18:39:51

标签: jpa

我正在尝试使用Eclipse 2018-09和Payara 5在开发中部署示例JSF 2.3应用程序,但它会向我返回此错误:

table1.objects.annotate(dt=Truncmonth('created')).values('dt').orderby().annotate(Count('dt'))
table1.objects.annotate(dte=Truncmonth('expires')).values('dte').orderby().annotate(Count('dte'))
table1.objects.annotate(dta=Truncmonth('activated')).values('dta').orderby().annotate(Count('dta'))
table1.objects.annotate(dtr=Truncmonth('renewed')).values('dtr').orderby().annotate(Count('dtr'))

这是我的using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml; using System.Xml.Linq; namespace ConsoleApplication1 { class Program { const string FILENAME = @"c:\temp\gps.xml"; static void Main(string[] args) { XDocument doc = XDocument.Load(FILENAME); XElement root = doc.Root; XNamespace ns = root.GetDefaultNamespace(); var results = doc.Descendants(ns + "trkpt").Select(x => new { lat = x.Attribute("lat"), lon = x.Attribute("lon"), ele = (decimal)x.Element(ns + "ele"), time = (DateTime)x.Element(ns + "time") }).ToList(); } } } 文件:

2018-10-14T15:19:42.783-0300|Severe: Exception during lifecycle processing java.io.IOException: org.xml.sax.SAXParseException; lineNumber: 8; 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.

这是我的控制台输出的摘录:

persistence.xml

我该如何解决?

谢谢。

1 个答案:

答案 0 :(得分:0)

您需要向persistence.xml文件提供持久性单元信息

这里是一个示例:https://www.thoughts-on-java.org/jpa-persistence-xml/

希望有帮助!