eclipse web.xml 文件中的语言服务器错误

问题描述

当我在 java ee eclipse 版本中创建动态 Web 项目时尝试自动生成 web.xml 文件时,它显示语言服务器错误。它将 web.xml 文件的此元素指示为错误

http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"

the error being

解决方法

这是 Eclipse 中的一个错误,自 2021 年 3 月起出现。

此处细分:https://github.com/eclipse/lemminx/issues/1042#issuecomment-859778034

好的,我可以用一个新的 Eclipse IDE(最后一个)重现这个问题。我可以解释这个问题,但我不知道如何解决它(目前)。

当您遇到 "There is '1' error in 'jakartaee_9.xsd'" 错误时,您必须打开 XSD 文件(从缓存中),您应该会看到 1 个错误和 1 个警告:

image

有一个警告:

schema_reference.4: Failed to read schema document 'platform:/plugin/org.eclipse.xsd/cache/www.w3.org/2001/xml.xsd',because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.  jakartaee_9.xsd /lemminx-cache/https/jakarta.ee/xml/ns/jakartaee    line 52 Language Servers

image

尝试在 xml.xsd 文件中定义 xml:lang 属性。但是这里无法检索 xml.xsd(警告消息),并且出现错误:

image

它尝试从 platform:/plugin/org.eclipse.xsd/cache/www.w3.org/2001/xml.xsd 下载 XSD,但平台特定于 Eclipse IDE。换句话说,当必须解析 http://www.w3.org/2001/xml.xsd 时,它表示 platform:/plugin/org.eclipse.xsd/cache/www.w3.org/2001/xml.xsd 是 XSD 的位置。我不知道是谁做的?

我的印象是 LemMinx 被配置为使用来自 WTP 的 XML 目录:

image

在等待带有修复程序的 Eclipse 版本(在撰写本文时确实尚未发布)时,一种解决方法是禁用 LemMinx 验证:

@chris21k 请注意,您可以禁用 LemMinx 验证:

image