在Spring Boot中,可以使用@Transactional注解来开启方法级别的事务。要使BBB方法的事务生效,可以在BBB方法上添加@Transactional注解。

示例代码如下:

public JSONObject AAA() throws Exception {
    // ...
    BBB();
    // ...
}

@Transactional
public JSONObject BBB() {
    // ...
}

在上述示例中,通过在BBB方法上添加@Transactional注解,即可使BBB方法被Spring事务管理器管理,并启用事务。

public JSONObject AAA throws Exception 		BBB;	public JSONObject BBB		springboot用注解怎么才能只使BBB方法的事务生效?

原文地址: https://www.cveoy.top/t/topic/iSiy 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录