Spring MVC - 没有为元素'mvc:annotation-drive'找到声明

时间:2014-04-05 06:02:49

标签: java spring spring-mvc

您好我收到以下错误。

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-drive'.

这是我的Spring上下文文件。

<?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:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:task="http://www.springframework.org/schema/task"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
            http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
            http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"
       default-lazy-init="true">
<context:component-scan base-package="com.demo.myapp"/>

    <mvc:annotation-drive />
</beans>

我搜索了很多,在Stackoverflow中找到了很多解决方案。但我仍然无法解决这个问题。我在这里做错了什么?

这是一个maven项目。早先不是Spring-mvc,我试图将其作为Spring-MVC项目。我在pom文件中添加了 spring-webmvc 依赖项。版本为3.1.3.RELEASE

1 个答案:

答案 0 :(得分:2)

<mvc:annotation-driven />而不是

<mvc:annotation-drive />
相关问题