Spring xml动态属性占位符构造 [英] Spring xml dynamic property placeholder construction
本文介绍了Spring xml动态属性占位符构造的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想动态构造一个属性值表达式,例如
I would like to dynamically construct a property value expression, as in
<property name="server" value="#{'${host}' + {systemProperties['myEnv']}}" />
假设属性托管服务器存在于属性文件中,其值为 myserver.net,并且系统属性myEnv已设置为'UAT',那么此表达式将得出'myserver.netUAT'的值。
Let's say the property host exists in a property file aand it's value is 'myserver.net' and the system property myEnv has been set to 'UAT', then this expression results in a value of 'myserver.netUAT'.
如果整个串联后进行评估。目前,它正在查找{host}键,然后附加属性。我希望它查找键$ {host.UAT}
What I would like if for the whole lot to be evaluated after the concatenation. Right now it's looking up {host} key then appending the property. I would like it to lookup the key ${host.UAT}
是否有可能实现这一目标。
Is it at all possible to achieve this.
推荐答案
这可行...
<util:properties id="props" location="foo.properties" />
<context:property-placeholder properties-ref="props" />
<bean id="foo" class="foo.Foo">
<property name="foo" value="#{props['${host}' + systemProperties['foo']]}" />
</bean>
这篇关于Spring xml动态属性占位符构造的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文