springboot和activiti整合时报错如下所示:
Parameter 0 of method springAsyncExecutor in org.activiti.spring.boot.AbstractProcessEngineAutoConfiguration required a single bean, but 3 were found: - asyncExecutor: defined by method 'asyncExecutor' in com.cngc.boot.security.config.CngcSecurityConfigurer - taskExecutor: defined by method 'taskExecutor' in com.cngc.boot.security.config.CngcSecurityConfigurer - taskScheduler: defined by method 'taskScheduler' in class path resource [org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfiguration.class]Action:Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumedDisconnected from the target VM, address: '127.0.0.1:57657', transport: 'socket'Process finished with exit code 1
这可以说是Activiti自动配置类中的一个错误。它依赖于它们TaskExecutor在应用程序上下文中唯一的一个bean,或者如果有多个bean,则它们中的一个是主要的。
您应该能够通过声明自己的TaskExecutorbean并将其标记为@Primary:解决该问题。
解决方法:在项目的Application启动类中添加以下代码即可。
@Primary
@Bean
public TaskExecutor primaryTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
return executor;
}