Java 配置全局线程池出错

错误内容:

Unsatisfied dependency expressed through field 'AAAAAAManager'; nested exception
is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'AAAAAAManagerImpl':
Unsatisfied dependency expressed through field 'globalThreadPoolExecutor'; nested exception is org.springframework.beans
.factory.NoSuchBeanDefinitionException: No qualifying bean of type
'java.util.concurrent.ThreadPoolExecutor' available: expected at least 1 bean which qualifies as autowire candidate.
Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

 

解决:

在设置全局线程池中,需要在类开始位置设置:@Configuration注解

 

Java 配置全局线程池出错

 

 

globalThreadPoolExecutor函数需要设置 Bean注解
@Bean
ThreadPoolExecutor globalThreadPoolExecutor(){
return new ThreadPoolExecutor(corePoolSize,
maximumPoolSize,
keepAliveTime,
TimeUnit.SECONDS,
new ArrayBlockingQueue<>(blockingQueueSize),
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.DiscardPolicy());
}
上一篇:beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘bra


下一篇:open-feign远程调用出错