Spring Boot 2.6.6 无法创建异步执行程序实例:无法实例化 [java.util.concurrent.Executor]:非法参数

Spring Boot 2.6.6 Failed to create asynch executor instance : Failed to instantiate [java.util.concurrent.Executor]: Illegal arguments

我正在升级 Spring 引导版本从 2.4.6 到 2.6.6

升级后,class 之一无法加载并出现如下错误:

Failed to instantiate [java.util.concurrent.Executor]: Illegal arguments to factory method 'threadPoolTaskExecutor'; args: ; nested exception is java.lang.IllegalArgumentException: object is not an instance of declaring class

创建执行程序服务实例失败class。

这是代码:

@Configuration
@EnableAsync
public class ApplicationAsynchConfig  implements AsyncConfigurer{
    
    @Bean(name = "threadPoolTaskExecutor")
    public Executor threadPoolTaskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        //set some properties
        return executor;
    }
  }

知道新的 Spring 启动版本有什么问题吗?

我不确定解决问题的方法,但在更改后应用程序启动并按预期工作。

解决方法是删除 AsyncConfigurer

代码如下:

@Configuration
@EnableAsync
public class ApplicationAsynchConfig {
    
    @Bean(name = "threadPoolTaskExecutor")
    public Executor threadPoolTaskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        //set some properties
        return executor;
    }
  }