升级到Spring Boot 2.1.6.RELEASE后,应用程序启动失败,并显示以下信息:
org.springframework.cloud.stream.binder.AbstractMessageChannelBinder中的字段集成流只需要一个bean,但是找到了2个:...
我正在尝试使用IntegrationFlowContext类手动注册流。
@Component
public class FlowCreator{
@Autowired
private IntegrationFlowContext flowContext;
@Autowired
private FlowExample flowExample;
@PostConstruct
public void registerIntegrationFlows() {
flowContext.registration(flowExample.integrationFlow1())
.id("integrationFlow1")
.register();
flowContext.registration(flowExample.integrationFlow2())
.id("integrationFlow2")
.register();
}
@Component
public class FlowExample {
public IntegrationFlow integrationFlow1() {
return IntegrationFlows.from("input")
.<Object, Class<?>>route(Object::getClass, routeMessages()) //
.get();
}
private Consumer<RouterSpec<Class<?>, MethodInvokingRouter>> routeMessages() {
return m -> m //
.subFlowMapping(Boolean.class, subFlow1())
.subFlowMapping(Integer.class, subFlow2())
.defaultOutputChannel("discardChannel");
}
private IntegrationFlow subFlow1() {
return sf -> sf.channel("Channel1");
}
private IntegrationFlow subFlow2() {
return sf -> sf.channel("Channel2");
}
public IntegrationFlow integrationFlow2() {
return IntegrationFlows.from("input")
.channel("channel3")
.get();
}
}
现在出现以下错误:
org.springframework.cloud.stream.binder.AbstractMessageChannelBinder中的字段集成流只需要一个bean,但是找到了2个:
答案 0 :(得分:1)
该问题已在Spring Cloud Stream 2.1.1
:https://github.com/spring-cloud/spring-cloud-stream/commit/794c75f5364b51d7ec89335b08bfaca0f6d4d139#diff-737803e2a91ac21a17baf06ff7b4cbac中修复。
考虑升级到Fishtown SR3
,甚至升级到Germantown GA
:https://spring.io/projects/spring-cloud-stream#learn