2015-04-05 40 views
7

无法找到春天 NamespaceHandler XML模式 命名空间 [http://www.springframework.org/schema/context]春3.0 - 无法找到春天NamespaceHandler为XML架构命名空间的背景下

SEVERE: Exception sending context initialized event to listener instance of 
class org.springframework.web.context.ContextLoaderListener 
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: 
Configuration problem: Unable to locate NamespaceHandler for namespace 
[http://www.springframework.org/schema/context] 
Offending resource: ServletContext resource [/WEB-INF/HelloWorld-service.xml] 

这是我的HelloWorld-service.xml中:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:p="http://www.springframework.org/schema/p" 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:util="http://www.springframework.org/schema/util" 
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 
    http://www.springframework.org/schema/util 
    http://www.springframework.org/schema/util/spring-util-3.0.xsd" 
    default-autowire="byName"> 

<context:component-scan base-package="com.test.service"> 
    <context:include-filter type="annotation" 
     expression="org.springframework.stereotype.Service"/> 
</context:component-scan> 

在我的pom.xml我有:

<properties> 
    <spring.version>3.0.5.RELEASE</spring.version> 
</properties> 
........ 
<dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>${spring.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context-support</artifactId> 
     <version>${spring.version}</version> 
    </dependency> 

项目树形结构:
enter image description here 任何想法可能是这个原因吗?

+0

尝试从pom.xml的 – Arpit 2015-04-06 14:26:15

+0

@Arpit去除 org.springframework 春天上下文 $ {} spring.version 。我试过兄弟。但没有运气:( – Unknown 2015-04-06 16:06:45

+0

你有类路径上的任何其他弹簧罐,即在应用程序服务器库文件夹的某处? – Setu 2015-04-09 16:25:51

回答

1

事实上,当我在eclipse下启动WebApp时会发生这种情况;我不知道为什么,看来Eclipse无法找到包含Spring XSD模式的弹簧罐 通常我通过在WEB-INF/lib目录下添加弹簧罐来解决它(通过使用在pom.xml中声明的相同名称)

1

如果您正在使用Eclipse的请尝试以下步骤:

上右键单击项目 - >属性 - >部署总成 - > Java构建路径entries-> Maven依赖

这意味着添加Maven依赖在您的部署程序集中

0

我已经成功使用弹簧BOM(“我的项目的POM材料里面“)法案:

<dependencyManagement> 
    <dependencies> 
     <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-framework-bom</artifactId> 
     <version>3.2.6.RELEASE</version> 
     <scope>import</scope> 
     <type>pom</type> 
     </dependency> 
    </dependencies> 
</dependencyManagement> 

earliest version of spring-framework-bom in maven central repository is 3.2.6.RELEASE,你将不得不迁移到一个不同的版本使用BOM。物料清单确保通过版本确定工件的一致解决方案。这也可以让你从你的依赖关系中删除所有<version>${spring.version}</version>

而且"versionless" xsd引用:

xsi:schemaLocation=" 
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context.xsd"> 
相关问题