求帅哥帮忙.添加一个线程池,配置文件写好了,怎么才能让ThreadPoolTaskExecutor知道我的配置信息是什么?

@Configuration

@PropertySource("classpath:application-dev.yml")

public class ThreadConfig {

//线程池维护线程的最少数量
@Value("${ThreaPool.corePoolSize}")
private Integer corePoolSize;
//允许的空闲时间
@Value("${ThreaPool.keepAliveSeconds}")
private Integer keepAliveSeconds;
//线程池维护线程的最大数量
@Value("${ThreaPool.maxPoolSize}")
private Integer maxPoolSize;
//缓存队列

@Value( "${ThreaPool.queueCapacity}")

private Integer queueCapacity;

@Bean
public TaskExecutor taskExecutor() {
   ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(corePoolSize);
    executor.setKeepAliveSeconds(keepAliveSeconds);
    executor.setMaxPoolSize(maxPoolSize);
    executor.setQueueCapacity(queueCapacity);
    ThreadPoolExecutor.CallerRunsPolicy callerRunsPolicy = 
            new ThreadPoolExecutor.CallerRunsPolicy();
    //对拒绝task的处理策略
    executor.setRejectedExecutionHandler(callerRunsPolicy);
    executor.initialize();
    return executor;
}

}

我用spring boot 添加了一个线程池
我把上面写bean注入进来了 ,注入的信息不是我配置的信息
我配置的这个线程池要怎么使用
import org.springframework.core.task.TaskExecutor;
    @Autowired
    public TaskExecutor taskExecutor;

你想问的应该是获取不到配置文件中的数值。

换成使用@Component注解

https://blog.csdn.net/dkbnull/article/details/81953190