zoukankan      html  css  js  c++  java
  • 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注解

     

    globalThreadPoolExecutor函数需要设置 Bean注解
    @Bean
    ThreadPoolExecutor globalThreadPoolExecutor(){
    return new ThreadPoolExecutor(corePoolSize,
    maximumPoolSize,
    keepAliveTime,
    TimeUnit.SECONDS,
    new ArrayBlockingQueue<>(blockingQueueSize),
    Executors.defaultThreadFactory(),
    new ThreadPoolExecutor.DiscardPolicy());
    }
    团队五人,专业从事软件开发,接单工作,专注于Java,.Net,PHP
  • 相关阅读:
    若不曾忘记,便不必追忆
    C# 随机生成中文字符串
    C# SQLiteHelper
    C# SQLHelper
    C# Microsoft SQL Server 操作
    C# Excel 操作
    C# XML文件操作(续)
    C# 遍历XML文件,添加,更新,删除节点
    MES系统简介
    SQL Server 存储过程(转)
  • 原文地址:https://www.cnblogs.com/xiaohouye/p/14735268.html
Copyright © 2011-2022 走看看