Spring集成出站网关希望像动态一样使用URL

spring集成,在outbound-gateway中想要像动态一样使用URL

     

Requestvalues就像这样简单的POJO

 @Data public class Requestvalues { public String Url; public String reqMethod; } 

org.springframework.beans.factory.BeanCreationException:创建名为’org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler#0’的bean时出错:无法创建[org.springframework]类型的内部bean’(内部bean)#6ea2bc93’。使用key [url]设置bean属性’uriVariableExpressions’时的integration.config.ExpressionFactoryBean]; 嵌套exception是org.springframework.beans.factory.BeanCreationException:创建名为’(内部bean)#6ea2bc93’的bean时出错:通过构造函数的Bean实例化失败; 嵌套exception是org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.integration.config.ExpressionFactoryBean]:构造函数抛出exception; 嵌套exception是java.lang.IllegalArgumentException:expressionString不能为空或null

您可以将URL或http方法等元数据设置为标题。 您甚至可以在设置标题时使用Spring EL

    

然后使用表达式为出站网关

   

http-method不是URI的一部分; 它不支持或使用uri-variables

请改用http-method-expression="payload.reqMethod"

类似地, Accept不是uri的一部分 – 在出站消息中设置Accept标头,它将被映射。

编辑

您正在使用bean声明表达式混淆运行时表达式,正如我所说,如果您想要选择运行时方法,则需要使用方法表达式。

但是,由于您正在为Requestvalues使用bean, Requestvalues根本不需要运行时表达式。

   

如果你想在运行时选择方法和url,根据消息,你会使用像…

    

标题是在上游某处动态设置的,或者

    

注意使用@来引用运行时表达式中的bean。