Camel-如何在以xml编写的路由中使用文件中设置的属性

时间:2018-11-08 11:16:28

标签: xml properties apache-camel

我在没有spring的骆驼xml路由中使用属性遇到了一些麻烦。我正在尝试使用“ to uri”标签中的属性,到目前为止,我已经实现了以下结果:

driver.find_element_by_xpath("//input[@name='331']")

url是诸如“ http4:// localhost:8080”之类的键,而定界符则是“?”的键。我使用此变通办法能够为http4组件使用throwExceptionOnFailure选项,并避免FailedToCreateRouteException。 还有另一种方法可以避免异常吗?我还试图使用simple和receiverList获得另一种解决方案,但是直到现在我只得到错误。

提前谢谢

1 个答案:

答案 0 :(得分:0)

您需要先确保已加载属性占位符,然后才能使用它。

PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class);
props.setLocation("classpath:yourfile.properties:);

在XML中:

<bean id="props" class="org.apache.camel.component.properties.PropertiesComponent">
  <property name="location" value="classpath:yourfile.properties" />
</bean>