将uri替换为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.cotainer.ComponentDefinitionException:无法验证xmlorg.xml.ax.SAXParseException:cvc复杂类型2.4.a:发现以元素"{"开头的无效内容http://camel.apache.org/schema/blueprint":endpoint}"。其中一个"{"http://camel.apache.org/schema/blueprint":应为路由}"。

答案是:

<route id="camel-http-proxy2">
<from uri="jetty://{{myuri}}"/>
</route>

我认为骆驼的文件没有更新。

您需要在属性占位符标记中添加配置文件。

<cm:property-placeholder id="myblueprint.placeholder" persistent-id="myprops">

然后可以将属性引用为${properties:myuri}{{myuri}}

最新更新