第一种 Transactional注解标注方法修饰符为非public时,@Transactional注解将会不起作用。
例如以下代码。
定义一个错误的@Transactional标注实现,修饰一个默认访问符的方法
/**
* @author zhoujy
**/
@Component
public class TestServiceImpl {
@Resource
TestMapper testMapper;
@Transactional
void insertTestWrongModifier() {
int re = testMapper.insert(new Test(10,20,30));
if (re > 0) {
throw new NeedToInterceptException("need intercept");
}
testMapper.insert(new Test(210,20,30));
}
}
在同一个包内,新建调用对象,