今天碰到一个奇怪的问题,spring在初始化xml配置文件的时候报错:
Cannot find the declaration of element 'beans'
spring配置文件原来是这样写的:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans org/springframework/beans/factory/xml/spring-beans-2.0.xsd"
default-lazy-init="true">
由于应用会有无互联网的环境下运行,同事将命名空间的引用改成了
org/springframework/beans/factory/xml/spring-beans-2.0.xsd
但不知道为什么在我本地上运行却不行
最后google了好几次才找到原因
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
classpath:/org/springframework/beans/factory/xml/spring-beans-2.0.xsd"
default-lazy-init="true">
需要增加“classpath:/”
原帖 http://www.jnan.org/archives/2010/12/cannot-find-the-declaration-of-element-beans.html
引用
Spring配置文件xsi:schemaLocation无法解析导致启动失败的解决方案
今天向服务器部署一个console java app之后,启动时发现程序出现异常:
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’.
然后去看看app-config.xml里的schema声明部分,是这样写的:
<beans xmlns=”http://www.springframework.org/schema/beans”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:context=”http://www.springframework.org/schema/context”
xsi:schemaLocation=”http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd” >
很明显,有关’beans’的声明都放在http://www.springframework.org/schema/beans/spring-beans-3.0.xsd里面了。可能是网络原因,访问不倒导致解析app-config.xml失败,致使程序抛出异常。
打开spring-beans-3.0.1.RELEASE.jar一看,那个xsd文件就在org.springframework.beans.factory.xml包下面,这下子好办了,把xsd文件的引用全改为本地的就行了:
<beans xmlns=”http://www.springframework.org/schema/beans”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:context=”http://www.springframework.org/schema/context”
xsi:schemaLocation=”http://www.springframework.org/schema/beans
classpath:/org/springframework/beans/factory/xml/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
classpath:/org/springframework/context/config/spring-context-3.0.xsd” >
分享到:
相关推荐
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dubbo:application'. - schema_reference.4: Failed to read schema document '...
西门子_CE DECLARATION of CONFORMITYpdf,
requirement analysis •conceptual database design •choice of the DBMS •data model mapping •physical design •implementation
TI-EU Declaration of Conformity (DoC)U Declaration of Conformity (DoC
RzBorder.pas Number of elements differs from declaration TRzLEDCharacters 在装完Raize控件之后编译老是出如下错误: [Pascal Error] RzBorder.pas(1429): E2072 Number of elements (125) differs from ...
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dubbo:application'. - schema_reference.4: Failed to read schema document '...
TI-EU Declaration of Conformity (DoC)U Declaration of Conformity (DoC
Java语言程序设计教程-电子教案,好不容易找来的啊,学java的看看吧
西门子_EG-Konformit�鋞serkl�鋜ung EC Declaration of Conformitypdf,
elsevier word 投稿模板, 方便不熟悉ctex的朋友
fs/yaffs2/yaffs_vfs.c:2383:2: error: implicit declaration of function 'get_sb_bdev' fs/yaffs2/yaffs_vfs.c: At top level: fs/yaffs2/yaffs_vfs.c:2390:2: error: unknown field 'get_sb' specified in ...
:person_rowing_boat: 筏 这是Go中Raft分布式共识算法的指导性实现。 它伴随着一系列博客文章: 该存储库中的每个partN目录都是博客文章系列N部分的完整源代码(第0部分除外,该部分是入门性的,没有代码)。...
浙江大学2004-2005学年冬季学期 《C Programming》课程期末考试试卷
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dubbo:application'. - schema_reference.4: Failed to read schema document '...
We can find find out the length of the variable by using the variable length . JSP string array String array cannot hold numbers or vice- versa. Arrays can only store the type of data specified at ...
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dubbo:application'. - schema_reference.4: Failed to read schema document '...
dubbo配置xml文件报错“Multiple annotations found at this line: - cvc-complex-type.2.4.c: The matching wildcard is ... 3) the root element of the document is not <xsd:schema>.” dubbo.xsd文件下载
Include the OutLookRichEdit.h file in the dialog's header file and change the declaration of rich edit member variable, as in CRichEditCtrl m_ctrlText1; to COutLookRichEdit m_ctrlText1; In InitDialog...
c#网络编程,编写网络应用程序是程序设计中最有趣的领域之一。眼看着自己编写的程序成功地通过网络实现了通信,这是特别令人振奋的