• 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
  • 相关阅读:
    叶问14
    叶问13
    叶问12
    叶问11
    叶问10
    叶问9
    Java三种循环之间的区别
    利用Java对象数组制作简易学生管理系统
    什么叫java方法重载?
    Java编译器的常量优化
  • 原文地址:https://www.cnblogs.com/xiaohouye/p/14735268.html
Copyright © 2020-2023  润新知