Spring 集成 HTTP 入站验证

Spring Integration HTTP Inbound Validation

我正在使用 SpringBoot 2.0 和 Spring Integration 5.0.3,我的 HTTP.inboundGateway 有问题。我的目标是验证发布到网关的 JSON,因为请求 pojo 包含必填字段。

 @Bean
 public IntegrationFlow notifyUpdateVehicleFlow() {
 return IntegrationFlows.from(Http.inboundGateway("/update")
        .requestMapping(r -> r.methods(HttpMethod.POST))
        .requestPayloadType(RequestPojo.class)
        .requestChannel(updateChannel())
        .replyChannel(updateReplyChannel()))
        .get();
 }

有没有简单的方法来验证 pojo 中的字段是否已设置?我已经测试过的是使用@NotNull SpringValidation 但似乎不支持 Spring Integration.

您好, 平滑

Spring 集成中没有这样的功能。您可以在 Http.inboundGateway() 的下游使用 .filter(),并在有效载荷上真正执行 Validator.validate()

如果您认为必须以某种方式在 Http.inboundGateway() 上完成并且您有强烈的要求和清晰的描述,请随时就此事提出 JIRA,我们将从框架的角度讨论可以做什么.