<mvc:annotation-driven>显示编译时错误</mvc:annotation-driven>

时间:2012-07-31 14:29:39

标签: java spring java-ee spring-mvc spring-webflow

<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"
    xmlns:aop="http://www.springframework.org/schema/aop"

    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

http://www.springframework.org/schema/aop 
                        http://www.springframework.org/schema/aop/spring-aop.xsd"
                        >

这是我的架构声明。但是mvc:annotation-driven它显示了编译时错误。 匹配的通配符是严格的,但是找不到元素的声明。我找不到合适的问题。所以请帮助找到这个问题。

错误: cvc-complex-type.2.4.c:匹配的通配符是strict,但是没有找到元素'mvc:annotation-driven'的声明。 你能告诉我这是什么问题吗?

2 个答案:

答案 0 :(得分:4)

您可能在类路径中缺少spring-webmvc - * .jar文件。

答案 1 :(得分:0)

刚刚创建了这个:

<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"
    xmlns:aop="http://www.springframework.org/schema/aop"

    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

http://www.springframework.org/schema/aop                         http://www.springframework.org/schema/aop/spring-aop.xsd

  

和简单的代码

  public static void main(String[] args) {
    System.out.println( new ClassPathXmlApplicationContext("1.xml").getBeanDefinitionCount() );
}

这显示0没有错误,所以这真的是因为缺少了@Biju Kunjummen的弹簧mvc jar(+1)

此外,您可能有2个不同版本的spring-mvc ...

相关问题