我试图为http4组件使用的代理设置,但没有效果。
文档给出了这个例子:
<camelContext>
<properties>
<property key="http.proxyHost" value="172.168.18.9"/>
<property key="http.proxyPort" value="8080"/>
</properties>
</camelContext>但那只是使用硬编码的值。
有办法在camelContext属性中使用占位符吗?
发布于 2015-07-31 11:24:16
首先,您需要PropertiesComponent来解析<camelContext>中的属性。
<bean id="propertiesComponent" class="org.apache.camel.component.properties.PropertiesComponent" />如果只需要支持以下内容之一,则不需要指定位置:
现在可以在camelContext属性中使用占位符:
<camelContext>
<properties>
<property key="http.proxyHost" value="{{http.proxyHost}}"/>
<property key="http.proxyPort" value="{{http.proxyPort}}"/>
</properties>
</camelContext>需要注意的另一件事是,如果不设置系统属性,这将失败。您可以(而且可能应该)在冒号之后指定默认值。
<property key="http.proxyHost" value="{{http.proxyHost:}}"/>
<property key="http.proxyPort" value="{{http.proxyPort:}}"/>以确保它在这两种情况下都有效。
https://stackoverflow.com/questions/31745003
复制相似问题