如何调用spring-xxx.jar包中的xsd文件?

张吉Jerry 2011-09-26 06:40:15
在写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里有没有相关的比较方便的方式来做这件事?
...全文
364 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
北京饼干 2011-09-27
  • 打赏
  • 举报
回复
我是来求加分的亲
[Quote=引用 3 楼 zhouyuqwert 的回复:]

把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……
[/Quote]
uastation 2011-09-27
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zhouyuqwert 的回复:]

把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……
[/Quote]

楼主可以一试..
阳明 to life 2011-09-26
  • 打赏
  • 举报
回复
把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">

德薄才浅 2011-09-26
  • 打赏
  • 举报
回复
补充eclipse->preferences->Web and XML
德薄才浅 2011-09-26
  • 打赏
  • 举报
回复
用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!!!!

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧