解决eclipse项目验证缓慢问题


用eclipse开发时,eclipse会验证项目,也可以在项目上右键->Validate来验证,这时候估计很多人会发现要等好一会儿eclipse才能验证完成,这是因为eclipse的验证是通过网络来验证的,网络不好到时候就会导致验证十分缓慢,解决办法就是让eclipse本地验证,不走网络验证。
开发中常用的验证文件格式也就是xsd和dtd,所以解决这两种格式文件的验证基本就可以解决问题。


一、下载文件

把需要的xsd和dtd文件下载到本地。

二、本地验证配置

window->preferences->xml->xml catalog->user specified entries->add->catalog entry
在location点file system选择下载好的文件

如果是xsd格式,key type选schema location,key填写你配置文件中xsi:schemaLocation后面的部分,例如

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context" 
    xsi:schemaLocation="
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">
</bean

则填写

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

如果是dtd格式,key type选择uri,key填写配置文件中的链接,例如

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

则填写

http://mybatis.org/dtd/mybatis-3-mapper.dtd

尽量打开所有你配置的文件看看,因为有些xsd文件里面可能还会引用其他xsd文件,这个时候把那些引用到的文件下载下来,按照相对路径关系(这样比较简单)配置好,才能防止某些情况下你确实配置好了所有文件,但是感觉验证依然很慢的问题(尤其是在spring项目里,这个问题尤为严重,众所周知,国内验证spring项目是很慢的)
比如:打开spring-context.xsd文件,搜索xsd:import,你会发现这里又引入了其他的xsd,这个时候你就需要把引入的xsd下载下来,以spring-too-4.3.xsd为例,,原始配置是这样的

<xsd:import namespace="http://www.springframework.org/schema/tool" schemaLocation="http://www.springframework.org/schema/tool/spring-tool-4.3.xsd"/>

将spring-tool-4.3.xsd文件与spring-context.xsd放在同一目录,按照相对路径关系,修改为

<xsd:import namespace="http://www.springframework.org/schema/tool" schemaLocation="spring-tool-4.3.xsd"/>

即可。目前我发现的需要修改的spring xsd文件有spring-context.xsd,spring-mvc.xsd,spring-tx.xsd,spring-aop.xsd,spring-util.xsd。
其他的就需要你自己打开去看看了。


将所有你用的验证文件依次配置好后,重启eclipse,然后你就会发现eclipse验证速度飞快,有质的改变。

原创不易,转发请注明出处—shizhongqi

猜你喜欢

转载自blog.csdn.net/lianjunzongsiling/article/details/74783781