The matching wildcard is strict, but no declaration can be found for element 'tx:annotation-driven'

后端 未结 9 2302
夕颜
夕颜 2020-11-29 09:11

I am trying to configure JSF+Spring+hibernate and I\'m tying to run a test but when I use this \"tx:annotation-driven\" on my application-context.xml file, I get this error:

相关标签:
9条回答
  • 2020-11-29 09:30

    FWIW I had this same issue. Turned out my xsi:schemaLocation entries were incorrect, so I went to the official docs and pasted theirs into mine:

    http://docs.spring.io/spring/docs/current/spring-framework-reference/html/transaction.html section 16.5.6

    I had to add a couple more but that was ok. Next up is to find out why this fixed the problem...

    0 讨论(0)
  • 2020-11-29 09:30

    I'm learning from udemy. I followed every step that my instructor show me to do. In spring mvc crud section while setting up the devlopment environment i had the same error for:

    <mvc:annotation-driven/> and <tx:annotation-driven transaction-manager="myTransactionManager" />
    

    then i just replaced

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

    with

        http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
    

    and

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

    with

        http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
    

    actually i visited these two sites http://www.springframework.org/schema/mvc/ and http://www.springframework.org/schema/tx/ and just added the latest version of spring-mvc and spring-tx i.e, spring-mvc-4.2.xsd and spring-tx-4.2.xsd

    So, i suggest to try this. Hope this helps. Thank you.

    0 讨论(0)
  • 2020-11-29 09:31

    For me the thing that worked was the order in which the namespaces were defined in the xsi:schemaLocation tag : [ since the version was all good and also it was transaction-manager already ]

    The error was with :

     http://www.springframework.org/schema/mvc
     http://www.springframework.org/schema/tx
     http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
     http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
    

    AND RESOLVED WITH :

    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
    
    0 讨论(0)
  • 2020-11-29 09:33

    One extra forward slash (/) in front of tx and the *.xml file troubled me for 8 hours!!

    My mistake:

    http://www.springframework.org/schema/tx/ http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
    

    Correction:

    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
    

    Indeed one character less/more manages to keep programmers busy for hours!

    0 讨论(0)
  • 2020-11-29 09:35

    You have some errors in your appcontext.xml:

    • Use *-2.5.xsd

      xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/aop 
        http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-2.5.xsd
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
      
    • Typos in tx:annotation-driven and context:component-scan (. instead of -)

      <tx:annotation-driven transaction-manager="transactionManager" />
      <context:component-scan base-package="com.mmycompany" />
      
    0 讨论(0)
  • 2020-11-29 09:38

    Make sure that Spring version and xsd version both are same.In my case I am using Spring 4.1.1 so my all xsd should be version *-4.1.xsd

    0 讨论(0)
提交回复
热议问题