首页 > 解决方案 > EnpointSpec 在 Spring Integration Java DSL 中失败

问题描述

@SpringBootApplication
@EnableIntegration
public class SpringIntegrationHttpApplication {

public static void main(String[] args) {
    SpringApplication.run(SpringIntegrationHttpApplication.class, args);
}

@Bean
public HttpRequestHandlerEndpointSpec httpInboundAdapter() {
    return Http
            .inboundChannelAdapter("/failing-test")
            .requestMapping(r -> r.methods(HttpMethod.GET)
                    .params("rObjectId"))
            .payloadExpression("#requestParams.rObjectId[0]")
            ;
}

@Bean
public IntegrationFlow myFlow() {
    return IntegrationFlows.from(Http
                    .inboundChannelAdapter("/test")
                    .requestMapping(r -> r.methods(HttpMethod.GET)
                    .params("rObjectId"))
            .payloadExpression("#requestParams.rObjectId[0]"))
            .transform(p -> p)
            .handle(p -> System.out.println(p))
            .get();
}

@Bean
public IntegrationFlow yourFlow() {
    return IntegrationFlows.from(httpInboundAdapter())
            .transform(p -> p)
            .handle(p -> System.out.println(p))
            .get();
}
}

对于上述代码,链接:/test 有效,但 /failing-test 无效。我在 chrome 上收到“端点已停止”。

可能是什么原因?

标签: spring-integrationspring-integration-http

解决方案


我不确定为什么,但是@Bean从规范中删除(只需使用返回规范的简单方法)。


推荐阅读