代码如下
抽象类
具体实现
事务配置,采用cglib来增强
期望是在doAdd方法上加事务管理,但实际调用的时候doAdd上并没有事务管理。原因是cglib不会对父类方法做增强
public interface IXService{
public void doAdd();
}
抽象类
public abstract class AbstractXService{
public void doAdd(){
//do something
innerMethod();
}
protected abstract void innerMethod();
}
具体实现
public class DXService{
protected void innerMethod(){...}
}
事务配置,采用cglib来增强
<aop:config proxy-target-class="true">
<aop:advisor pointcut="execution(* DXService.*(..))" advice-ref="txAdvice"/>
</aop:config>
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="doAdd" propagation="REQUIRED" rollback-for="java.lang.Throwable"/>
</tx:attributes>
</tx:advice>
期望是在doAdd方法上加事务管理,但实际调用的时候doAdd上并没有事务管理。原因是cglib不会对父类方法做增强