SpringBoot使用@Async时,如下方式会失效


1. 异步方法使用static关键字时,会失效

2. 异步类实例必需由Spring管理,如果没有使用@Component等注解,无法扫描到,当然也就不生效

3. 异步方法不能与异步方法在同一个类中

4. 类中需要使用@Autowired或@Resource等注解自动注入,不能自己手动new对象

5. 如果使用SpringBoot框架必须在启动类中增加@EnableAsync注解

6. 在Async 方法上标注@Transactional是没用的。 在Async 方法调用的方法上标注@Transactional 有效。