微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

org.xml.sax.SAXParseException: Failed to read schema document 的原因分析与解决方法

现象:

org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema documen
t 'http://www.springframework.org/schema/beans/spring-beans-3.1.xsd',because 1)
Could not find the document; 2) the document Could not be read; 3) the root ele
ment of the document is not <xsd:schema>.


分析:
参考http://www.jb51.cc/article/p-kovsojxe-sp.html
这篇文章分析的比较深入,具体原因为:
根据xx.jar\meta-inf\spring.schemas文件,先在本地查找相关xsd文件,如果本地没有,则通过网络去获取实际上上面问题往往出现在没有网络的服务器上(本地正常,传到服务器上,而服务器一般是不能访问外网的)
但该文章并没有讲清楚更具体的处理措施,只是说了最好用maven的shade打包插件而不是assembly


处理:

必须在 <transformers> 里面加上下面内容


<transformerimplementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>meta-inf/spring.handlers</resource>
</transformer>
<resource>meta-inf/spring.schemas</resource>

</transformer>


才会出现“shade能够将所有jar里的spring.schemas文件进行合并,在最终生成的单一jar包里,spring.schemas包含了所有出现过的版本的集合!”效果


参考


http://mapserver000-gmail-com.iteye.com/blog/1182499

http://shuhucy.iteye.com/blog/1771684

http://stackoverflow.com/questions/8523997/unable-to-locate-spring-namespacehandler-for-xml-schema-namespace-http-www-sp/8574629#8574629

http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html

http://maven.apache.org/plugins/maven-shade-plugin/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念
xml文件介绍及使用
xml编程(一)-xml语法
XML文件结构和基本语法
第2章 包装类