注释类型 Async
@Target({TYPE,METHOD}) @Retention(RUNTIME) @Documented public @interface Async
Annotation that marks a method as a candidate for asynchronous execution. Can also be used at the type level, in which case all of the type's methods are considered as asynchronous. Note, however, that@Asyncis not supported on methods declared within a@Configurationclass.In terms of target method signatures, any parameter types are supported. However, the return type is constrained to either
voidorFuture. In the latter case, you may declare the more specificListenableFutureorCompletableFuturetypes which allow for richer interaction with the asynchronous task and for immediate composition with further processing steps.A
Futurehandle returned from the proxy will be an actual asynchronousFuturethat can be used to track the result of the asynchronous method execution. However, since the target method needs to implement the same signature, it will have to return a temporaryFuturehandle that just passes a value through: e.g. Spring'sAsyncResult, EJB 3.1'sAsyncResult, orCompletableFuture.completedFuture(Object).- 从以下版本开始:
- 3.0
- 作者:
- Juergen Hoeller, Chris Beams
- 另请参阅:
AnnotationAsyncExecutionInterceptor,AsyncAnnotationAdvisor
元素详细资料
value
String value
A qualifier value for the specified asynchronous operation(s).May be used to determine the target executor to be used when executing the asynchronous operation(s), matching the qualifier value (or the bean name) of a specific
ExecutororTaskExecutorbean definition.When specified on a class-level
@Asyncannotation, indicates that the given executor should be used for all methods within the class. Method-level use ofAsync#valuealways overrides any value set at the class level.- 从以下版本开始:
- 3.1.2
- 默认值:
- ""