我有以下代码:
/**
* Restored deleted partner
*/
@Transactional
public void restorePartnerById(Integer id){
// logic
}
当我使方法最终化时
/**
* Restored deleted partner
*/
@Transactional
public final void restorePartnerById(Integer id){
// logic
}
我收到一个编译错误:
Methods annotated with
@Transactional
must be overridable
我四处寻找,但我无法理解为什么它必须是可覆盖的,为什么该方法必须是可覆盖的?
最佳答案
Spring 的Transactional与创建覆盖方法的代理类一起工作:
create a transactional proxy around the object that is created from the fooService bean definition. The proxy will be configured with the transactional advice, so that when an appropriate method is invoked on the proxy
关于java - 为什么用@Transactional 注释的方法必须是可覆盖的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52715125/