I want spring to load the default ThreadPoolTaskExecutor
from TaskExecutionAutoConfiguration
. Though I want to provide may own additional executor for some explicit side-tasks:
@Bean
public ThreadPoolExecutor myRequestPool() {
return (ThreadPoolExecutor) Executors.newFixedThreadPool(10);
}
Problem: adding the bean above, the TaskExecutionAutoConfiguration
will not be executed anymore, and the spring-default executor will not be initialized, because @ConditionalOnMissingBean(Executor.class)
does not match anymore:
package org.springframework.boot.autoconfigure.task;
public class TaskExecutionAutoConfiguration {
@Lazy
@Bean(name = APPLICATION_TASK_EXECUTOR_BEAN_NAME)
@ConditionalOnMissingBean(Executor.class)
public ThreadPoolTaskExecutor applicationTaskExecutor(TaskExecutorBuilder builder) {
return builder.build();
}
Question: how can I still let spring create both beans?