错误内容:
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注解
globalThreadPoolExecutor函数需要设置 Bean注解
@Bean
ThreadPoolExecutor globalThreadPoolExecutor(){
return new ThreadPoolExecutor(corePoolSize,
maximumPoolSize,
keepAliveTime,
TimeUnit.SECONDS,
new ArrayBlockingQueue<>(blockingQueueSize),
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.DiscardPolicy());
}