Reputation: 2251
I have the following error while using spring boot to run activiti and web sockets together:
Parameter 0 of method springAsyncExecutor in org.activiti.spring.boot.AbstractProcessEngineAutoConfiguration required a single bean, but 4 were found:
- clientInboundChannelExecutor: defined by method 'clientInboundChannelExecutor' in class path resource [org/springframework/web/socket/config/annotation/DelegatingWebSocketMessageBrokerConfiguration.class]
- clientOutboundChannelExecutor: defined by method 'clientOutboundChannelExecutor' in class path resource [org/springframework/web/socket/config/annotation/DelegatingWebSocketMessageBrokerConfiguration.class]
- brokerChannelExecutor: defined by method 'brokerChannelExecutor' in class path resource [org/springframework/web/socket/config/annotation/DelegatingWebSocketMessageBrokerConfiguration.class]
- messageBrokerTaskScheduler: defined by method 'messageBrokerTaskScheduler' in class path resource [org/springframework/web/socket/config/annotation/DelegatingWebSocketMessageBrokerConfiguration.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 consumed
As spring boot uses abstract configuration, do I have to override some configurations?
Thanks for your help.
Upvotes: 2
Views: 4800
Reputation: 116091
That's arguably a bug in Activiti's auto-configuration class. It's relying on their only being a single TaskExecutor
bean in the application context or, if there are multiple beans, for one of them to be primary.
You should be able to work around the problem by declaring your own TaskExecutor
bean and marking it as @Primary
:
@Configuration
class SomeConfiguration {
@Primary
@Bean
public TaskExecutor primaryTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
// Customize executor as appropriate
return executor;
}
}
Upvotes: 3