Eclipse中开发过程中出现Referenced file contains errors (xml文件第一行小红叉错误)

在Eclipse中开发过程中,有时导入工程时经常出现,工程可以正常运行,但是xml文件时第一行无缘无故报错。在最左面的行数上面报出一个小红叉。

报错信息:

Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-4.0.xsd). For more information, right click on the message in 
 the Problems View and select "Show Details..."

Eclipse中开发过程中出现Referenced file contains errors (xml文件第一行小红叉错误)

 Eclipse中开发过程中出现Referenced file contains errors (xml文件第一行小红叉错误)

解决方法:

第一种:点击eclipse左上角菜单栏 Project->clean  清理更新一下你所出现问题的项目。不仅这个问题,还有很多奇怪的问题都可以通过这种方式解决。

第二种:首先为了确保 Eclipse 可以从远程拿到 xsd 文件,到 Window -> Preferences -> General -> Network Connections -> Cache 下的 Cache entries 框内检查所需要的文件是否正确,如果不确定,就点击 "Remove All",然后右击当前的 Project 选择 Validator,Eclipse 会重新加载 xsd 文件;
Eclipse中开发过程中出现Referenced file contains errors (xml文件第一行小红叉错误)

完成后clean一下项目

第三种:如果错误依旧,那就需要删掉 xsd 文件的版本号,例如:

http://www.springframework.org/schema/context/spring-context-3.0.xsd

改成: http://www.springframework.org/schema/context/spring-context.xsd