在下面的代码中,
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();
}
}
简单答案:是的,
bean.method()
调用将尊重@Transactional
注释。在执行数据层操作时,将创建一个事务并完成其工作。