maven—spring- junit 解析applicationContext.xml出错

来源:互联网 发布:合肥网络优化 编辑:程序博客网 时间:2024/05/07 01:17

问题:

  maven 工程分三个部分  database <-service<-webapp(后面依赖前一个module)

  在webapp的pom.xml中有spring的依赖, eclipse中可以看见service下的maven dependencies的有spring,所以没在意,迷惑人。。

    在/src/test中写了一个测试类Config,准备读取spring的appicationContext.xml(拷贝1份放置于src/test/resources)

 

 

Unable to locate Spring NamespaceHandler for XML错误原因

严重: Context initialization failed
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:/ ............./applicationContext.xml]

也就是说解析配置文件出错,

1 开始以为是版本问题,寻找到webapp中的pom.xml,发现是正确的。

2 查下看applicationContext.xml的命名空间,书写正确。

 

 

最后找到以前配置正确的maven工程:spring的jar配置放在database里,(database <-service<-webapp)项目结构也是类似的。

原来:是当前module里,eclipse编译后运行寻找不到spring相关的jar,自然是解析applicationContext.xml出错,

添加后,问题解决

原创粉丝点击