`
talentluke
  • 浏览: 592146 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Spring配置文件xsi:schemaLocation无法解析导致启动失败的解决方案

 
阅读更多

来源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” >
分享到:
评论

相关推荐

    xml中的xmlns:、xmlns:xsi和xsi:schemaLocation.doc

    xml中的xmlns:、xmlns:xsi和xsi:schemaLocation。

    SpringMVC配置文件最全约束

    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=

    spring声明式事务配置

    &lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;beansxmlns=......

    Dell 15R 5521安装WinXP

    Dell 15R 5521安装WinXP方法及驱动下载链接

    spring框架配置bean的高级属性

    可以利用hibernate tools生成相关映射文件已经po对象、dao... xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"&gt; &lt;!--配置数据源--&gt;

    springmvc-config.xml

    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配置文件详细配置说明

    Maven的pom.xml配置文件详细配置说明 &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=...

    Spring实战2-Bean注入详解的源代码

    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 ...

    spring2.0声明式事务

    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头部文件模板实例详解

    普通spring配置文件模板: &lt;?xml version=1.0 encoding=UTF-8 ?&gt; &lt;beans xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns=http://www.springframework.org/schema/beans xsi:schemaLocation...

    springbootMaven配置文件,用于更改资源下载路径,避免初始化项目报错

    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"&gt; &lt;localRepository&gt;D:\repository\mavenrepository &lt;!-- proxy | Specification for...

    配置文件pom.xml

    Windows下Eclipse配置Appium环境资料 &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=...

    Spring XML 配置扩展机制

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd ...

    springweb3.0MVC注解(附实例)

    web.xml 中定义了一个名为 annomvc 的 Spring MVC 模块,按照 Spring MVC 的契约,需要在 WEB-INF/annomvc-servlet.xml 配置文件中定义 Spring MVC 模块的具体配置。annomvc-servlet.xml 的配置内容如下所示: ...

    asp.net_spring_nhibernate_oracle

    xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd" 】好多地方不加入,这样做没错,但是出现错误不报错。因此一定要加。 提示三:用oracle的,一定...

    SpringBoot整合Freemarker.docx

    修改pom文件,添加坐标freemarker启动器坐标 &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=...

    spring applicationContext 配置文件

    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 ...

    项目源码java京东商城购物网站

    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 ...

    Spring Boot Socket实现与html页面的连接,案例讲解客户端与服务器端相互发消息.docx

    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"&gt; &lt;modelVersion&gt;4.0.0 &lt;groupId&gt;org.springframework.boot &lt;artifactId&gt;spring-boot-starter-parent ...

    spring-ibatis

    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 ...

Global site tag (gtag.js) - Google Analytics