[英]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]:工厂方法“threadPoolTaskExecutor”的参数非法; 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.