![](/img/trans.png)
[英]Eclipse Plugin Development - ClassCastException cannot cast abc.xyz to abc.xyz
[英]override property value ${abc.xyz} in bean property in spring configuration file
我有bean xml文件,該文件會加載多個屬性文件以創建其bean。 所有這些屬性文件都位於根文件夾下,例如root / abc / abc.properties,root / xyz / some.properties等。
<bean id="x".....
....
<util:properties id="properties" location="${config.base.dir}/abc/abc.properties" />
......
</bean>
<bean id="y".....
....
<util:properties id="properties" location="${config.base.dir}/xyz/some.properties" />
......
</bean>
我想覆蓋config.base.dir的值放在頂部,以便我可以不斷更改根位置,是否應該通過在頂部定義一些屬性來實現?
如果使用Maven,則可以在test / resources / abc /文件夾中擁有abc.properties版本。 這將在main / resources / abc / abc.properties文件之前的類路徑中獲取。
這有幫助嗎?
為什么要“不斷更改根位置”?
系統屬性覆蓋...
<!-- Configuration property files -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName">
<value>SYSTEM_PROPERTIES_MODE_OVERRIDE</value>
</property>
<property name="locations">
<list>
<value>classpath*:config.properties</value>
</list>
</property>
</bean>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.