![daaf03fbafe33dbb9e6d92c73305796a.png](https://i-blog.csdnimg.cn/blog_migrate/5f73f4180f34426206be2e5877f66806.jpeg)
作者:hepingfly
出自:InfoQ 写作平台
原文:xie.infoq.cn/article/82a53233c7bc89969e2fd2513
两个重要的注解:
@Async
- @
EnableAsync
1)、先说一下不用异步任务的情况:
// SpringBoot 主启动类
@SpringBootApplication
public class SpringbootApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootApplication.class, args);
}
}
//--------------------------------controller----------------------------------------------
@RestController
public class AsyncController {
@Autowired
private AsyncService asyncService;
@GetMapping("/helloHepingFly")
public String helloHepingF