【问题标题】:no declaration can be found for element 'tx:annotation-driven'找不到元素“tx:annotation-driven”的声明
【发布时间】:2016-05-06 08:45:10
【问题描述】:

我正在为我的项目使用 spring 4.1.1,我收到以下异常。以下是我正在使用的定义,需要帮助!

xmlns:tx="http://www.springframework.org/schema/tx" 
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-4.1.xsd"

【问题讨论】:

    标签: java xml spring xsd spring-transactions


    【解决方案1】:

    确保您的类路径具有 spring-tx 依赖项。如果你使用 maven 添加依赖

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>4.1.1.RELEASE</version>
    </dependency>
    

    如果您已经拥有依赖项,请检查版本,因为它可能不是 4.1。

    您还可以声明您的命名空间省略版本,以便它始终选择最新的

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

    如果您确实需要特定于版本的某些功能,请指定版本

    【讨论】:

    • 添加 spring-tx 后错误已解决,但现在我得到如下新异常 java.lang.NoClassDefFoundError: org/springframework/transaction/interceptor/TransactionInterceptor
    猜你喜欢
    • 2013-03-02
    • 2011-08-28
    • 2016-04-19
    • 2012-02-19
    • 1970-01-01
    • 1970-01-01
    • 2018-04-12
    • 2012-07-02
    • 2012-11-28
    相关资源
    最近更新 更多