我的Eclipse工作区中有很多Spring项目。有时它们都经过验证而没有错误。但是,有时各种Spring配置XML文件显示如下错误:
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'
cvc-elt.1: Cannot find the declaration of element 'beans'.
Referenced file contains errors(http://www.springframework.org/schema/context/spring-context.xssd). For more information, right click...
我只需打开文件,右键点击并选择“验证”即可解决错误。这将导致XML验证器重新验证文件,错误将消失。我还清理了整个工作区,并允许eclipse重建/重新验证所有内容,有时它们会消失。
但是,如果刷新项目并重新运行验证,则很多时候错误将重新出现。
有谁知道为什么会这样?我不相信XML文件确实存在错误。有没有一个技巧可以帮助XML验证器避免混淆?
以下是其中一个文件显示其中一些错误的开头:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd"
default-autowire="byName">