Spring加载XSD文件小结(解决nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreE)

Spring版本如下:


原先项目使用到的Spring版本为2.5,后来升级版本为3.2,对应XML文件中schema引用的XSD标签版本为



后来因为项目统一Spring版本原因,统一回退到Spring 2.5,Spring jar包版本回退到2.5,但是标签还是写的3.2,如下:



这样子就会导致应用启动正常,而访问接口时候出现如下错误:



关键错误信息:nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException


原因分析

<?xml version="1.0" encoding="UTF-8"?>
<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
                        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">

如此配置,Spring会先在本地查找xsd文件,即Spring 2.5的jar中,如下图:

spring-2.5.6/META-INF/spring.schemas 


注意此处兼容2.0版本,Spring找不到映射的3.2xsd文件,然后就去外网查,即

访问地址http://www.springframework.org/schema/beans/spring-beans-3.2.xsd获取xsd文件


因为我应用是在内网,故通过外网也走不通了。


心得

保证xsd标签版本小于spring版本(通常等于就可以了),通过外网方式获取xsd的方式不可取,一旦外网断了问题就会暴露。

参考博客:http://blog.csdn.net/bluishglc/article/details/7596118




  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值