Using Spring Boot 3.1.3
My Application class:
@SpringBootApplication
@EnableAsync
public class Application {
public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
}
My rest controller:
@RestController
public class MainController {
@GetMapping
@Async
public Future<String> show() {
return CompletableFuture.completedFuture("Jordi");
}
}
The response of the operation is:
{
"cancelled": false,
"done": true
}
When it should be “Jordi”.
However if I remove the @Async annotation it works as expected.
Am I doing something wrong?