Java Spring引导抽象自动配置问题
使用spring boot同时运行activiti和web套接字时,我出现以下错误:Java Spring引导抽象自动配置问题,java,spring,spring-boot,Java,Spring,Spring Boot,使用spring boot同时运行activiti和web套接字时,我出现以下错误: Parameter 0 of method springAsyncExecutor in org.activiti.spring.boot.AbstractProcessEngineAutoConfiguration required a single bean, but 4 were found: - clientInboundChannelExecutor: defined by method 'clien
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使用抽象配置,我是否必须覆盖某些配置
感谢您的帮助。这可能是Activiti自动配置类中的一个bug。这取决于它们在应用程序上下文中只是一个
TaskExecutor
bean,或者,如果有多个bean,则其中一个bean是主bean
您应该能够通过声明自己的TaskExecutor
bean并将其标记为@Primary
:
@Configuration
class SomeConfiguration {
@Primary
@Bean
public TaskExecutor primaryTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
// Customize executor as appropriate
return executor;
}
}
很好,通过创建我自己的TaskExecutor作为主要任务执行器,它成功了。所以你是对的,这是Activiti的自动配置类中的一个bug。