We can enable asynchronous processing by simply adding @EnableAsync to a configuration class, as follows:
@Configuration
@EnableAsync
public class AppConfig {
@Bean
public AsyncTask asyncTask() {
return new AsyncTask();
}
}
In the previous code, we have not provided TaskExecutor as a bean, so Spring will use a default SimpleAsyncTaskExecutor implicitly.