通过接口自动装配时派生方法上的Spring @Transactional

问题描述 投票:0回答:1

在下面的代码中,

bean.method()
会调用尊重
@Transactional
注释吗?

public interface Iface {
    void method();
}

@Component
public class Derived implements Iface {
    @Override
    @Transactional
    public void method() {
        // some logic
    }
}

@Component
public class SomeComponent {

    @Autowired
    private Iface bean;

    public void someCall() {
        bean.method();
    }
}
java spring
1个回答
0
投票

简单答案:是的,

bean.method()
调用将尊重
@Transactional
注释。在执行数据层操作时,将创建一个事务并完成其工作。

© www.soinside.com 2019 - 2024. All rights reserved.