Spring Boot 3 Invalid return type for async method (only Future and void supported): class java.lang.Boolean

Spring Boot About 291 words

错误信息

Invalid return type for async method (only Future and void supported): class java.lang.Boolean

错误原因

@Async标注的方法,返回值设置为了Boolean

解决方法

将返回值改为voidFuture

@Async
public Future<Boolean> asyncTask() {
    // TODO asyncTask
    return CompletableFuture.completedFuture(Boolean.TRUE);
}
Views: 847 · Posted: 2024-03-20

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh