Vicky
Vicky

Reputation: 93

<mvc:annotation-driven /> shows compile time error

<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"
                        >

This is my schema declaration. But mvc:annotation-driven it shows compile time error. The matching wildcard is strict, but no declaration can be found for element. I could not find the problem properly. So please help for finding this problem.

Error: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'. Can you please tell me what is the problem?

Upvotes: 2

Views: 2603

Answers (2)

Andrey Borisov
Andrey Borisov

Reputation: 3170

just created this:

<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"

and trivial code

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

This shows 0 without error, so really this is because missing of spring-mvc jar as per @Biju Kunjummen(+1)

Also you may have 2 different versions of spring-mvc...

Upvotes: 0

Biju Kunjummen
Biju Kunjummen

Reputation: 49915

You are probably missing spring-webmvc-*.jar file in your classpath.

Upvotes: 4

Related Questions