vani reddy
vani reddy

Reputation: 21

cvc-complex-type.2.4.a: Invalid content was found starting with element 'annotation-driven'

Below i have pasted my servlet-context.xml.I am getting the error in spring toolsuite in the line where I have declared the annotation-driven tag

cvc-complex-type.2.4.a: Invalid content was found starting with element 'annotation-driven'. One of '{"http://www.springframework.org/schema/beans":description, "http://
 www.springframework.org/schema/beans":import, "http://www.springframework.org/schema/beans":alias, "http://www.springframework.org/schema/beans":bean, 
 WC[##other:"http://www.springframework.org/schema/beans"]}' is expected.






<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="http://www.springframework.org/schema/beans" 
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

    <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->`enter code here`



    <!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven />

    <beans:bean id="productManager" class="com.manthan.service.SimpleProductManager">
        <beans:property name="products">
            <beans:list>
                <beans:ref bean="product1"/>
                <beans:ref bean="product2"/>
                <beans:ref bean="product3"/>
            </beans:list>
        </beans:property>
    </beans:bean>

        <context:component-scan base-package="com.manthan.vani" />

</beans:beans>

I am a beginner and working on Spring tool suite 3.7.0

Upvotes: 2

Views: 10903

Answers (1)

Paulius Matulionis
Paulius Matulionis

Reputation: 23415

Change:

xmlns:mvc="http://www.springframework.org/schema/mvc"

to

xmlns="http://www.springframework.org/schema/mvc"

or make:

<mvc:annotation-driven />

Your currect configuration has prefix "mvc" which doesn't point to the default namespace and annotation-driven comes from mvc schema.

Upvotes: 4

Related Questions