Sunday, April 27, 2014

Resolve Element 'mvc:annotation-driven' must have no character

To resolve the error

cvc-complex-type.2.1: Element 'mvc:annotation-driven' must have no character or element information item [children], because the type's content type is empty.

chagne the mvc schemaLocation to newer version, for example, 3.2 works for me.
<beans xmlns="http://www.springframework.org/schema/beans"
        ...
 xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        ...
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">

2 comments:

  1. Replies
    1. Glad to be helpful.

      And also found that it's not necessary to specify the version in the schema for newer version of Spring, for example,

      xsi:schemaLocation="
      http://www.springframework.org/schema/beans
      ...
      http://www.springframework.org/schema/mvc
      http://www.springframework.org/schema/mvc/spring-mvc.xsd'>

      works for me on Spring 4.x. Did not try it with Spring 3.x and earlier thought.

      Delete