【问题标题】:Spring MVC - no declaration can be found for element 'mvc:annotation-drive'Spring MVC - 找不到元素'mvc:annotation-drive'的声明
【发布时间】:2014-04-05 06:02:48
【问题描述】:

您好,我收到以下错误。

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

【问题讨论】:

    标签: java spring spring-mvc


    【解决方案1】:

    &lt;mvc:annotation-driven /&gt; 而不是

    <mvc:annotation-drive />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-18
      • 1970-01-01
      • 2017-09-17
      • 1970-01-01
      • 2012-07-02
      • 2012-11-28
      • 2012-09-14
      相关资源
      最近更新 更多