【问题标题】:Does Sequence of method names in which they are specified in spring-aop-transaction.xml matter?在 spring-aop-transaction.xml 中指定的方法名称序列是否重要?
【发布时间】:2017-02-21 11:22:13
【问题描述】:

我在我的项目中遇到了一个 spring-aop-transaction.xml 文件。 有两个部分。

<aop:config>
    <aop:advisor
        pointcut="execution

这里所有的接口都被声明了。 和

<tx:advice id="TxAdvice" transaction-manager="transactionManager">
        <tx:attributes>

这里指定了所有方法名称。 我想知道提到方法名称的顺序是否有所不同,或者它们必须与接口声明的顺序完全相同。

感谢您的回答。

编辑: 如何强制关闭一个打开的事务。

前:

<tx:method name="updateData" propagation="REQUIRES_NEW"
    rollback-for="Exception"/>

此事务被另一种方法继续使用,从而产生问题。 提前致谢。

【问题讨论】:

    标签: java spring spring-aop spring-transactions pointcut


    【解决方案1】:

    您可以为您的方面标记顺序优先级,这意味着您的建议有效地按顺序运行http://docs.spring.io/spring/docs/current/spring-framework-reference/html/aop.html#aop-ataspectj-advice-ordering

    @Order(2)

    因此,当多个点切割与目标匹配时,建议会根据优先顺序执行,这意味着@Order(1) 标记的方面(建议)在@Order(2) 之前执行

    您可以在此处查看已完成的示例 Ordering aspects with Spring AOP && MVC

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-09
      • 1970-01-01
      • 1970-01-01
      • 2010-12-27
      • 2020-09-20
      相关资源
      最近更新 更多