Unable to locate Spring NamespaceHandler for XML schema namespace
2015-02-26 14:34
429 查看
今天在测试NetBeans打包的jar包程序的时候发现一个诡异的spring异常,此异常在IDE调试中不存在,但在测试环境中打包后即出现,错误日志如下
Exception in thread "AWT-EventQueue-0" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: file [D:\work\ccsweb\test\exe\applicationContext.xml]
异常出现的原因是
如果工程中依赖了Spring的多个依赖,在打包时后面的会把前面的覆盖,使得这两个文件中永远只保存最后一个spring依赖的schema和handler
解决方法
我使用netbeans自带的build.xml编译的,所以不知道怎么修改配置文件。自己测试了一个简洁的方法,就是根据提示少的那行内容,在打好Jar底下的
META-INF文件夹中找到spring.handler如下图
![](http://img.blog.csdn.net/20150226162128984?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveGlhb3podTJoYW8=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
原来spring.handlers的内容是如下:
http\://www.springframework.org/schema/aop=org.springframework.aop.config.AopNamespaceHandler
手动添加上一行
http\://www.springframework.org/schema/context=org.springframework.context.config.ContextNamespaceHandler
问题解决
Exception in thread "AWT-EventQueue-0" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: file [D:\work\ccsweb\test\exe\applicationContext.xml]
异常出现的原因是
如果工程中依赖了Spring的多个依赖,在打包时后面的会把前面的覆盖,使得这两个文件中永远只保存最后一个spring依赖的schema和handler
解决方法
我使用netbeans自带的build.xml编译的,所以不知道怎么修改配置文件。自己测试了一个简洁的方法,就是根据提示少的那行内容,在打好Jar底下的
META-INF文件夹中找到spring.handler如下图
原来spring.handlers的内容是如下:
http\://www.springframework.org/schema/aop=org.springframework.aop.config.AopNamespaceHandler
手动添加上一行
http\://www.springframework.org/schema/context=org.springframework.context.config.ContextNamespaceHandler
问题解决
相关文章推荐
- Unable to locate Spring NamespaceHandler for XML schema namespace
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- Unable to locate Spring NamespaceHandler for XML schema namespace
- Unable to locate Spring NamespaceHandler for XML schema namespace异常解决
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- spring 与 CXF 整合 webservice 出现error “Unable to locate Spring NamespaceHandler for XML schema namespace” 总结
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- Unable to locate Spring NamespaceHandler for XML schema namespace问题排查
- Unable to locate Spring NamespaceHandler for XML schema namespace
- transaction 用tx事务 测试时 报错:Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/mvc]
- Unable to locate Spring NamespaceHandler for XML schema namespace异常
- Spring 3.0: Unable to locate Spring NamespaceHandler for XML schema namespace
- 解决Unable to locate Spring NamespaceHandler for XML schema namespace
- spring报错Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/aop]
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://ww
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- Unable to locate Spring NamespaceHandler for XML schema namespace
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- onfiguration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security]