简体   繁体   English

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

I am upgrading Spring Boot version from 2.4.6 to 2.6.6我正在将 Spring Boot 版本从 2.4.6 升级到 2.6.6

After upgrade, one of the class failed to load and giving an error like below:升级后,其中一个类无法加载并给出如下错误:

Failed to instantiate [java.util.concurrent.Executor]: Illegal arguments to factory method 'threadPoolTaskExecutor';无法实例化 [java.util.concurrent.Executor]:工厂方法“threadPoolTask​​Executor”的参数非法; args: ;参数:; nested exception is java.lang.IllegalArgumentException: object is not an instance of declaring class嵌套异常是 java.lang.IllegalArgumentException: object is not an instance of declaring class

It failed to create a instance of executor service class.它未能创建执行程序服务类的实例。

This is the code:这是代码:

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

Any idea what is going wrong with the new Spring Boot version for this?知道新的 Spring Boot 版本出了什么问题吗?

I am not sure about the approach to solve the issue but after the changes the application started and working as expected.我不确定解决问题的方法,但在更改后应用程序启动并按预期工作。

The solution is to remove the AsyncConfigurer解决方案是删除AsyncConfigurer

Here is the code:这是代码:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否有.Net等效于java.util.concurrent.Executor? - Is there a .Net equivalent to java.util.concurrent.Executor? 使用java.util.concurrent.Executor会阻止tomcat停止 - Use of java.util.concurrent.Executor stops tomcat from stopping 停止java.util.concurrent.Executor任务的方法 - Way to stop java.util.concurrent.Executor task java.util.concurrent.Executor如何工作? - How does java.util.concurrent.Executor work? Spring:无法将TaskExecutorImpl类型的值转换为java.util.concurrent.Executor - Spring : Cannot convert value of type TaskExecutorImpl to java.util.concurrent.Executor Java - 使用通用执行程序服务实例进行并发处理 - Java - Concurrent processing with a common executor service instance Spring data elasticsearch:throws MappingInstantiationException: Failed to instantiate java.util.Set using constructor NO_CONSTRUCTOR with arguments - Spring data elasticsearch:throws MappingInstantiationException: Failed to instantiate java.util.Set using constructor NO_CONSTRUCTOR with arguments 弹簧启动警告。 需要一个 Executor 来处理 java.util.concurrent.Callable - Springboot Warning! An Executor is required to handle java.util.concurrent.Callable java.util.concurrent:从Runnable到Executor接口的过渡 - java.util.concurrent: Transition from Runnable to Executor interface spring boot - 如何在HTTP控制器处理程序中避免“无法实例化[java.util.List]:指定的类是一个接口”? - spring boot - how to avoid “Failed to instantiate [java.util.List]: Specified class is an interface” in HTTP controller handler?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM