Spring @Async
2021-02-11 11:19
标签:except nts print thread 返回 操作 turn out tac Spring @Async 标签:except nts print thread 返回 操作 turn out tac 原文地址:https://www.cnblogs.com/itplay/p/12736183.html引入
@SpringBootApplication
@EnableAsync
public class ProjectApplication {
public static void main(String[] args) {
SpringApplication.run(ProjectApplication.class, args);
}
}
使用
@Slf4j
public class TestService {
@Async
@Transactional //事务无效
public void asyncVoid() {
TestService testService = SpringUtil.getBean(TestService.class); //获取代理类proxy
testService.update(); //事务有效
System.out.println("无返回值方法");
}
@Async
@Transactional //事务无效
public Future