79360773

Date: 2025-01-16 08:09:03
Score: 1
Natty:
Report link

Make sure you already have @EnableAsync in your @configuration file

   @Configuration
    @EnableAsync
    public class AsyncConfig implements AsyncConfigurer {
    
      @Override
      @Bean
      public Executor getAsyncExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(3);
        executor.setMaxPoolSize(9);
        executor.setQueueCapacity(50);
        executor.setThreadNamePrefix("MyExecutor-");
        executor.initialize();
        return executor;
      }

here some references about it

https://www.baeldung.com/spring-async

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @EnableAsync
  • User mentioned (0): @configuration
  • Low reputation (1):
Posted by: nyomanc