我正在构建一些部署在OSGi (JBoss引线)中的驼峰路由
我正在使用下面的代码读取属性文件:
<ext:property-placeholder id="propiedades">
<ext:location>file:/C:/TestBed/sucursal.propiedades</ext:location>
</ext:property-placeholder>但现在我想要更改"file:/C:TestBed/“作为具有某些路径的占位符(如KARAF_ETC)。我知道这个环境变量存在,因为当我在路由中使用它时,它工作得很好。
from(URI_IN)
.log("{{env:KARAF_ETC}}") //Output is: C:\jboss-fuse-6.2.0.redhat-133\bin\..\etc
.to(URI_OUT);所以,我想做一些类似的事情:
<ext:property-placeholder id="propiedades">
<ext:location>file:{{env:KARAF_ETC}}/sucursal.propiedades</ext:location>
</ext:property-placeholder>但不起作用。
属性占位符有点棘手,所以我尝试了file:/{{env:KARAF_ETC}},file:/{{KARAF_ETC}},file:${KARAF_ETC}和更多的组合,但没有人工作(但其中一些抛出了不同的错误)。
在蓝图中获取环境变量的正确汉化是什么?
发布于 2015-08-04 15:51:53
你试过这个吗?
<blueprint
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
...>
<!-- Load system property -->
<ext:property-placeholder />
<bean ...><property name="foobar" value="${foobar}"/></bean>
</blueprint> 我在这里找到了它:http://karaf.922171.n3.nabble.com/Get-environment-variable-td4025807.html
发布于 2015-08-05 03:50:24
可以使用karaf.something访问karaf环境变量,但在camel中可以使用KARAF_SOMETHING访问
感谢克劳斯·易卜生指出了范围的不同之处。
然而,这种camel/osgi的东西真的是weird...It很难驯服……
发布于 2017-08-31 21:45:34
这对我来说很有效:
<propertyPlaceholder id="properties" location="file:${karaf.home}/etc/sucursal.properties"/>https://stackoverflow.com/questions/31794470
复制相似问题