Spring引导抽象自动配置问题 [英] Spring boot abstract auto configuration problems
问题描述
使用spring boot同时运行activiti和web套接字时出现以下错误:
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
由于spring boot使用抽象配置,我是否必须覆盖某些配置?
As spring boot uses abstract configuration, do I have to override some configurations?
感谢您的帮助。
推荐答案
这可能是一个错误Activiti的自动配置类。它依赖于它们在应用程序上下文中只是一个 TaskExecutor
bean,或者,如果有多个bean,则其中一个是主要的。
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.
您应该能够通过声明自己的 TaskExecutor
bean并将其标记为 @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;
}
}
这篇关于Spring引导抽象自动配置问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!