http://jinnianshilongnian.iteye.com/blog/1901693 This blog explains it in more detail. The summary is: 1. When the @Aysnc method has no transaction, use Future.get( ) can obtain the results of the asynchronous thread in the main thread. 2. When @Async has a transaction, remove the asynchronous configuration in Spring's test configuration file so that @Async fails and is tested as synchronously.
http://jinnianshilongnian.iteye.com/blog/1901693
This blog explains it in more detail. The summary is:
1. When the @Aysnc method has no transaction, use Future.get( ) can obtain the results of the asynchronous thread in the main thread.
2. When @Async has a transaction, remove the asynchronous configuration in Spring's test configuration file so that @Async fails and is tested as synchronously.