maven:Referenced file contains errors

转载自:https://www.cnblogs.com/zjfjava/p/6950290.html

applicationContext.xml 文件头报错Referenced file contains errors

问题如下:原先运行正常的项目,突然在applicationContext.xml 文件头报错

    

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

原因分析:如果使用Maven构建项目,spring在加载xsd文件时总是先试图在本地查找xsd文件(spring的jar包中已经包含了所有版本的xsd文件),如果没有找到,才会转向去URL指定的路径下载。所以出现该情况一般是因为断网或spring的官网暂时无法连接导致的。 可以通过在浏览器输入xsd文件的URL,如:spring-beans的话,输入http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 进行确认。

但是这次我没有使用Maven,jar包都是在本地发布的,所以排除以上原因。

换个思路:

1. 首先为了确保 Eclipse 可以从远程拿到 xsd 文件,到 Window -> Preferences -> General -> Network Connections -> Cache 下的 Cache entries 框内检查所需要的文件是否正确,如果不确定,就点击 "Remove All",然后右击当前的 Project 选择 Validator,Eclipse 会重新加载 xsd 文件;

                 

 

2. 最简捷的方法是删掉 xsd 文件的版本号(这里已经删除了,但仍报错,故采取method 1)。

猜你喜欢

转载自blog.csdn.net/ncuzengxiebo/article/details/80782282