防止在 Java 属性中评估系统 properties/variables?
Prevent system properties/variables being evaluated in Java properties?
我正在使用 Spring 加载属性:
<util:properties id="service-properties">
...
<prop key="postScript"></prop>
...
</util:properties>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="propertyConfigurer"><property name="properties" ref="service-properties" />
</bean>
然而,其中一个属性可以有如下值(这是一个骆驼xml简单的语言片段):
postScript=<setBody><simple>${in.header.type}</simple></setBody>
问题是,当我得到这个 属性 的值时,它是:
postScript=<setBody><simple></simple></setBody>
我认为它似乎在尝试解析 ${in.header.type} 变量,认为它可能是一个系统变量?
我想知道如何停止解析这个变量?我试过用引号转义它但没有用。
从 Camel 文档中得到了答案:-)
http://camel.apache.org/simple.html
Alternative syntax
From Camel 2.5 onwards you can also use the alternative syntax which uses $simple{ } as placeholders.
This can be used in situations to avoid clashes when using for example Spring property placeholder together with Camel.
我正在使用 Spring 加载属性:
<util:properties id="service-properties">
...
<prop key="postScript"></prop>
...
</util:properties>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="propertyConfigurer"><property name="properties" ref="service-properties" />
</bean>
然而,其中一个属性可以有如下值(这是一个骆驼xml简单的语言片段):
postScript=<setBody><simple>${in.header.type}</simple></setBody>
问题是,当我得到这个 属性 的值时,它是:
postScript=<setBody><simple></simple></setBody>
我认为它似乎在尝试解析 ${in.header.type} 变量,认为它可能是一个系统变量?
我想知道如何停止解析这个变量?我试过用引号转义它但没有用。
从 Camel 文档中得到了答案:-)
http://camel.apache.org/simple.html
Alternative syntax
From Camel 2.5 onwards you can also use the alternative syntax which uses $simple{ } as placeholders. This can be used in situations to avoid clashes when using for example Spring property placeholder together with Camel.