Original: http://www.cnblogs.com/azhqiang/p/5609615.html
The meaning of Enableasync annotation is that it can be executed asynchronously, that is, to turn on multithreading. Can be labeled on methods, classes.
1 @Component2 Public classTask {3 4 @Async5 Public voidDotaskone ()throwsException {6 //Above content, omitted7 }8 9 @AsyncTen Public voidDotasktwo ()throwsException { One //Above content, omitted A } - - @Async the Public voidDotaskthree ()throwsException { - //Above content, omitted - } - +}
In order for the @async annotation to take effect, you will also need to configure @enableasync in the main program of spring boot, as follows:
1 @SpringBootApplication 2 @EnableAsync 3 public class application { 4 public static void main (string[] args) { 6 springapplication.run (application. Class 7 8 9 }
Note: @Async the modified function is not defined as a static type, so the asynchronous call does not take effect
(GO) Spring boot note [email protected] asynchronous call