Spring集成出站网关希望像动态一样使用URL [英] Spring integration outbound-gateway want to use URL as dynamic like
问题描述
spring集成,在出站网关中希望将URL用作动态类似
spring Integration,in outbound-gateway want to use URL as dynamic like
<bean id="requestValues" class="com.src.model.RequestValues"/>
<int-http:outbound-gateway
request-channel="reqChannel" url="${UrlValue}"
http-method="${reqmethod}" expected-response-type="java.lang.String" header-mapper="headerMapper"
charset="UTF-8" reply-timeout="5000" reply-channel="responseChannel" >
<int-http:uri-variable name="UrlValue" expression="#{requestValues.getUrl()}" />
<int-http:uri-variable name="reqmethod" expression="#{requestValues.getReqMethod()}" />
</int-http:outbound-gateway>
此处Requestvalues很简单POJO
就像
Here Requestvalues is simple POJO it like
@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.integration.config.ExpressionFactoryBean]类型的内部bean'(内部bean)#6ea2bc93'使用键[url]设置bean属性'uriVariableExpressions'时;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'(内部bean)#6ea2bc93'的bean时出错:通过构造函数的Bean实例化失败;嵌套异常是org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.integration.config.ExpressionFactoryBean]:构造函数抛出异常;嵌套异常是java.lang.IllegalArgumentException:expressionString不能为空或null
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler#0': Cannot create inner bean '(inner bean)#6ea2bc93' of type [org.springframework.integration.config.ExpressionFactoryBean] while setting bean property 'uriVariableExpressions' with key [url]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#6ea2bc93': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.integration.config.ExpressionFactoryBean]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: expressionString must not be empty or null
推荐答案
你可以将URL或http方法等元数据设置为标题。您甚至可以在设置标题时使用Spring EL,例如。
You can set meta data like URL or http method as headers. You can even use Spring EL when setting the header, f.e.
<int:header-enricher>
<int:header name="url" value="${url.base}/reports/"/>
</int:header-enricher>
然后使用表达式作为出站网关
and then use an expression for the outbound gateway
<int-http:outbound-gateway id='httpGateway'
url-expression="headers['url']"
...
/>
这篇关于Spring集成出站网关希望像动态一样使用URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!