Complete the code to enable asynchronous processing in a Spring Boot method.
@[1]
public void processTask() {
// task logic here
}The @Async annotation tells Spring Boot to run this method asynchronously.
Complete the code to enable async support in a Spring Boot application.
@Configuration @[1] public class AsyncConfig { }
The @EnableAsync annotation enables Spring's asynchronous method execution capability.
Fix the error in the method signature to return a future result asynchronously.
@Async
public [1]<String> fetchData() {
// fetch data logic
}CompletableFuture is commonly used in Spring Boot for async methods returning results.
Fill both blanks to create a method that runs asynchronously and returns a completed future.
@Async public CompletableFuture<String> [1]() { return CompletableFuture.[2]("Done"); }
The method name can be runTask, and completedFuture returns a completed CompletableFuture.
Fill all three blanks to configure a custom executor bean for async processing.
@Bean public Executor [1]() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize([2]); executor.setMaxPoolSize([3]); executor.initialize(); return executor; }
The bean name asyncExecutor is common, with core pool size 5 and max pool size 10 for thread management.