英文:
Replace uri with property from configuration file in xml
问题
<route id="camel-http-proxy2">
<from uri="jetty://${myuri}"/>
</route>
<endpoint id="input1" uri="jetty://${myuri}"/>
<route id="camel-http-proxy2">
<from uri="ref:input1"/>
</route>
英文:
How can I replace the uri with the text from configuration file myprops.cfg
?
<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
my try:
<route id="camel-http-proxy2">
<from uri="jetty://${myuri}"/>
</route>
Then the camel read the uri as it is, it doesnt replace it with the value of the property.
another try:
<endpoint id="input1" uri="jetty//${myuri}"/>
<route id="camel-http-proxy2">
<from uri="ref:input1"/>
</route>
error:
> 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}'. One of '{"http://camel.apache.org/schema/blueprint":route}' is expected.
答案1
得分: 1
答案是:
<route id="camel-http-proxy2">
<from uri="jetty://{{myuri}}"/>
</route>
Camel的文档可能没有更新。
英文:
The answer is:
<route id="camel-http-proxy2">
<from uri="jetty://{{myuri}}"/>
</route>
The documentation of camel is not updated I think.
答案2
得分: 1
你需要将配置文件添加到property-placeholder标签内。
<cm:property-placeholder id="myblueprint.placeholder" persistent-id="myprops">
然后可以通过${properties:myuri}
或{{myuri}}
来引用该属性。
英文:
You need to add the config file within the property-placeholder tag.
<cm:property-placeholder id="myblueprint.placeholder" persistent-id="myprops">
You can then reference the property as ${properties:myuri}
or {{myuri}}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论