[英]Replace uri with property from configuration file in xml
如何用配置文件myprops.cfg
中的文本替換 uri?
<route id="camel-http-proxy2">
<from uri="jetty://http://127.0.0.1:5555/mock"/>
</route>
myprops.cfg:
myuri=http://127.0.0.1:555/mock
我的嘗試:
<route id="camel-http-proxy2">
<from uri="jetty://${myuri}"/>
</route>
然后駱駝按原樣讀取uri,它不會用屬性的值替換它。
另一個嘗試:
<endpoint id="input1" uri="jetty//${myuri}"/>
<route id="camel-http-proxy2">
<from uri="ref:input1"/>
</route>
錯誤:
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element '{" http://camel. apache.org/schema/blueprint ":endpoint}'。 '{" http://camel.apache.org/schema/blueprint ":route}' 之一是預期的。
答案是:
<route id="camel-http-proxy2">
<from uri="jetty://{{myuri}}"/>
</route>
我認為駱駝的文檔沒有更新。
您需要在 property-placeholder 標記中添加配置文件。
<cm:property-placeholder id="myblueprint.placeholder" persistent-id="myprops">
然后,您可以將該屬性引用為${properties:myuri}
或{{myuri}}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.