Spring异步实现方式

Spring 实现异步方式:

在需要异步执行的方法头上加@Async

配置文件:

xmlns:task="http://www.springframework.org/schema/task"
http://www.springframework.org/schema/task/spring-task.xsd

<task:annotation-driven/>

需要注意的一点:@Async和@Transactional一起加到方法头上,事务会失效。经实践表明,一般
@Async标注在controller的方法头上,service层按照传统的方式写就可以了。
原文地址:https://www.cnblogs.com/jqlbj/p/7208330.html