mvc:annotation-driven在Spring中不起作用

fas*_*ava 2 spring annotations spring-mvc

我有<mvc:annotation-driven/>错误的注释.我得到的错误是:匹配的通配符是严格的,但是没有找到元素'mvc:annotation-driven'的声明.

当我用豆子的时候

<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
Run Code Online (Sandbox Code Playgroud)

它工作正常.怎么可能

我完整的Spring上下文XML文件是:

<beans xmlns="http://www.springframework.org/schema/beans"
            xmlns:context="http://www.springframework.org/schema/
         xmlns:mvc="http://www.springframework.org/schema/mvc"
        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-2.5.xsd
       http://www.springframework.org/schema/context             http://www.springframework.org/schema/context/spring-context-2.5.xsd
   http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-2.5.xsd">

    <mvc:annotation-driven/>
</beans>
Run Code Online (Sandbox Code Playgroud)

Bor*_*hov 5

我相信mvc:annotation-drivenSpring 2.5中没有注释,我认为它是在Spring 3.0引入的.考虑使用当前版本的Spring.

我找不到实际的http://www.springframework.org/schema/mvc/spring-mvc-2.5.xsd我不确定它是否存在.