cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'tx:annotation- driven'

StackOverflow https://stackoverflow.com/questions/23290699

  •  09-07-2023
  •  | 
  •  

Pregunta

My mvc-dispatcher-servlet.xml:::

<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:tx="http://www.springframework.org/schema/tx"  
        xsi:schemaLocation="
            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">

    <context:property-placeholder location="classpath:resources/database.properties" />
        <context:component-scan base-package="com.suva.*" />
         <tx:annotation-driven transaction-manager="hibernateTransactionManager"/>  

        <bean
            class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix">
                <value>/WEB-INF/pages/</value>
            </property>
            <property name="suffix">
                <value>.jsp</value>
            </property>
        </bean>



     <bean id="dataSource"  
      class="org.springframework.jdbc.datasource.DriverManagerDataSource">  
      <property name="driverClassName" value="${database.driver}" />  
      <property name="url" value="${database.url}" />  
      <property name="username" value="${database.user}" />  
      <property name="password" value="${database.password}" />  
     </bean>  



     <bean id="sessionFactory"  
      class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">  
      <property name="dataSource" ref="dataSource" />  
      <property name="hibernateProperties">  
       <props>  
        <prop key="hibernate.dialect">${hibernate.dialect}</prop>  
        <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>  
        <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>      
       </props>  
      </property>  
     </bean>  

    </beans>

I am doing a spring-security application where i have to add DB validation with spring-security framework. I have included proper jar in the class path but i am facing this compilation error.. Please point me out where i am wrong..

¿Fue útil?

Solución

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:lang="http://www.springframework.org/schema/lang"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

I have changed my xsd to this xsd definitions and it is working now.. As like Pathfinder2104 is saying, spring automatically takes the most recent available xsd. so better not to mention the version of the xsd.

Otros consejos

You just want to add following line of codes.

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

And,

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

Hope this will work.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top