来源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/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/contexthttp://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/beansclasspath:/org/springframework/beans/factory/xml/spring-beans-3.0.xsdhttp://www.springframework.org/schema/contextclasspath:/org/springframework/context/config/spring-context-3.0.xsd” >
相关推荐
xml中的xmlns:、xmlns:xsi和xsi:schemaLocation。
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" ... xsi:schemaLocation=
<?xml version="1.0" encoding="UTF-8"?><beansxmlns=......
Dell 15R 5521安装WinXP方法及驱动下载链接
可以利用hibernate tools生成相关映射文件已经po对象、dao... xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!--配置数据源-->
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/mvc ...
Maven的pom.xml配置文件详细配置说明 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=...
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 ...
xsi:schemaLocation=” http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx ...
普通spring配置文件模板: <?xml version=1.0 encoding=UTF-8 ?> <beans xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns=http://www.springframework.org/schema/beans xsi:schemaLocation...
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository>D:\repository\mavenrepository <!-- proxy | Specification for...
Windows下Eclipse配置Appium环境资料 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=...
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd ...
web.xml 中定义了一个名为 annomvc 的 Spring MVC 模块,按照 Spring MVC 的契约,需要在 WEB-INF/annomvc-servlet.xml 配置文件中定义 Spring MVC 模块的具体配置。annomvc-servlet.xml 的配置内容如下所示: ...
xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd" 】好多地方不加入,这样做没错,但是出现错误不报错。因此一定要加。 提示三:用oracle的,一定...
修改pom文件,添加坐标freemarker启动器坐标 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=...
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context ...
xsi:schemaLocation= "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx ...
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0 <groupId>org.springframework.boot <artifactId>spring-boot-starter-parent ...
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/mvc ...