今天部署一个jar包的时候遇到一个问题:
Exception in thread “main” org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from class path resource [app-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘beans’
或者:
schema_reference.4:无法读取方案文档 http://www.springframework.org/schema/aop/spring-aop-3.0.xsd,原因是1)无法找到文档 2)无法读取文档 3)文档的根元素不是xsd:schema.
caused by java.net.ConnectionException:Connection timed out:connect.
这个很让我无语了,本地都是好好的,为什么在服务器上就不行了,后来才知道服务器是无外网环境的,由于程序用了spring,在加载applicationContext.xml的时候会报上述错误。
主要的原因是在applicationContext.xml文件里要根据namespace找schemaLocation的地址,如果没有配置schemaLocation的话,就找namespace下的地址,由于未联网,所以会失败,解决办法是讲原有的:
改成:
这样就可以了
参考:
http://blog.csdn.net/dingqinghu/article/details/46758671
http://www.jnan.org/archives/2010/12/cannot-find-the-declaration-of-element-beans.html
————————————————
版权声明:本文为CSDN博主「玉羽凌风」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zhouyan8603/article/details/48315039