在写applicationContext.xml时需要指定xsi:schemaLocation,一般是一个网址,如http://www.springframework.org/schema/context/spring-context-3.0.xsd,但如果网络不通,那启动的时候就会出问题。
临时的解决方法是把这个文件下载下来,打包到jar中,不过似乎有些麻烦。
我看到spring-xxx.jar包中是有xsd文件的,如org/springframework/context/config/spring-context-3.0.xsd,有没有办法直接调这里的xsd?
另外,maven里有没有相关的比较方便的方式来做这件事?

解决方案 »

  1.   

    用RAR把spring-XXX.jar解压到一个指定的目录,然后到eclipse->web and xml->XML Catalog 新建一个(Add)
    1、location:放刚刚解压出来的文件找到spring-context-3.0.xsd
    2、Key Type:选择System ID
    3、Key:http://www.springframework.org/schema/context/spring-context-3.0.xsd
    ok!!!!
      

  2.   

    补充eclipse->preferences->Web and XML
      

  3.   

    把xsd或者dtd拷贝出来到相对路径
    比如在同一路径下的spring-beans-3.1.xsd
    <beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans spring-beans-3.1.xsd">
    如果看着前面一堆URL不爽也可以删掉xsd里面的命名空间 然后引用的时候也可以去掉
    xsd里面
    <xsd:schema 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    >
    xml里面
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="spring-beans-3.1.xsd">
    引用dtd的话也一样 拷贝出来放在相对位置
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "spring-beans.dtd">