今天在Eclipse导入项目时,web-inf出现红叉,百度无果后自行研究。
出现错误的文件是web.xml
<web-app
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0"
>
错误是:
There is ‘1’ error in ‘javaee_7.xsd’.
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.).
有一篇国外的博客上说,这是Eclipse的一个错误,从21年3月份就出现了。
出现这个错误的时候,打开XSD文件可以看到一个错误一个警告
警告: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
尝试在xml.xsd文件中定义xml:lang属性,但是这里无法检索sml.xsd,并出现错误、
解决方法:
一,等待带有修复程序的Eclipse版本
二,禁用LemMinx验证:
在windows->preferences 中,选择XML(Wild Web)
点击Validation 将Enable validation的选中取消即可