日期:2014-05-20  浏览次数:20650 次

如何调用spring-xxx.jar包中的xsd文件?
在写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里有没有相关的比较方便的方式来做这件事?

------解决方案--------------------
用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!!!!

------解决方案--------------------
把xsd或者dtd拷贝出来到相对路径
比如在同一路径下的spring-beans-3.1.xsd
XML code
<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">

------解决方案--------------------
探讨

把xsd或者dtd拷贝出来到相对路径
比如在同一路径下的spring-beans-3.1.xsd
XML code
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http……

------解决方案--------------------
我是来求加分的亲
探讨

把xsd或者dtd拷贝出来到相对路径
比如在同一路径下的spring-beans-3.1.xsd
XML code
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http……