【问题标题】:Does tx:annotation-driven respect beans imported and does the order of service import matter?tx:annotation-driven 是否尊重导入的 bean,服务导入的顺序是否重要?
【发布时间】:2012-02-27 05:08:45
【问题描述】:

您好,我有以下问题。

根据 spring docs tx:annotation-driven 仅尊重它定义的 bean 定义。

但是我有以下代码

<import resource="applicationContext-service1.xml"/>
<import resource="applicationContext-service2.xml"/>
<import resource="applicationContext-service3.xml"/> 
<tx:annotation-driven/>

" 仅在定义它的同一应用程序上下文中的 bean 上查找 @Transactional。这意味着,如果您将 ".

我在 service1、2、3 中有明确的 bean ...

1.) 我真的必须将 tx:annotation-driven 添加到 applicationContext-service1.xml ...等吗? 2.) 导入资源的顺序对事务边界的创建是否重要。

【问题讨论】:

    标签: spring transactions import annotations


    【解决方案1】:

    应用程序上下文不是 XML 文件。导入文件中声明的所有 bean 都是同一应用程序上下文的一部分。而且顺序无关紧要。

    【讨论】:

      猜你喜欢
      • 2013-08-11
      • 1970-01-01
      • 1970-01-01
      • 2018-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多