无法找到XML架构命名空间的Spring NamespaceHandler [http://www.springframework.org/schema/mvc]

时间:2013-12-06 21:25:23

标签: java spring maven spring-mvc

我有以下错误。我不明白为什么。

[INFO] org.springframework.beans.factory.parsing.BeanDefinitionParsingException: 
Configuration problem: Unable to locate Spring NamespaceHandler for XML schema
namespace [http://www.springframework.org/schema/mvc]

你有解决方案吗?

谢谢

我的pom.xml的Spring依赖项:

    <!-- Spring MVC framework -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>2.5.6</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>2.5.6</version>
    </dependency>

我的spring-servlet.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd">

     <context:component-scan base-package="com.application.myGoogleAppEngine.controller" />
    <mvc:annotation-driven />
    <bean id="helloBean" class="com.application.myGoogleAppEngine.HelloWorld">
       <property name="name" value="Mkyong" />
    </bean>

    <bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
          <property name="defaultLocale" value="fr" />
    </bean>

    <bean id="localeChangeInterceptor"
    class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
         <property name="paramName" value="language" />
    </bean>

    <bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" id="messageSource"> 
           <property value="classpath:MessageBundle" name="basename"/> 
           <property value="UTF-8" name="defaultEncoding"/> 
    </bean>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
         <property value="org.springframework.web.servlet.view.JstlView" name="viewClass"/>
         <property name="prefix">
            <value>/WEB-INF/pages/</value>
         </property>
         <property name="suffix">
             <value>.jsp</value>
         </property>
     </bean>

 </beans>

1 个答案:

答案 0 :(得分:0)

MvcNamespaceHandler是在Spring 3.0中引入的,所以如果你想要注释驱动的MVC上下文,你需要升级到更新版本的Spring

/**
 * {@link NamespaceHandler} for Spring MVC configuration namespace.
 *
 * @author Keith Donald
 * @author Jeremy Grelle
 * @since 3.0
 */
public class MvcNamespaceHandler extends NamespaceHandlerSupport {
...
}