小编Dhr*_*del的帖子

@Async无法用于返回类型为void的方法

我想做一个使用@Async注解以异步方式写入数据库的方法。

我用注解标记了该类@EnableAsync

@EnableAsync
public class FacialRecognitionAsyncImpl {

    @Async
    public void populateDataInPushQueue(int mediaId, int studentId) {
        //myCode
    }
}
Run Code Online (Sandbox Code Playgroud)

在调用该populateDataInPushQueue方法时,写操作应在另一个线程中执行,并且流程应从我正在调用此方法的类中继续。但这没有发生,程序执行正在等待此方法完成。

java spring asynchronous spring-annotations spring-boot

4
推荐指数
2
解决办法
213
查看次数