Omr*_*mri 4 xml spring placeholder javabeans
我在我的一个Spring(3.1)XML中定义了以下属性文件:
<context:property-placeholder location="classpath:MyConfigFile.properties"/>
Run Code Online (Sandbox Code Playgroud)
我希望能够定义第二个可选属性文件,该文件将覆盖"MyConfigFile.properties"文件并将被加载而不是它.
换句话说,我希望我的应用程序加载"MyConfigFile.properties"文件,但如果在类路径中有"StrogerConfigFile.properties",它将被加载.
任何人都知道如何使用Spring XML完成它?
pap*_*pap 13
<context:property-placeholder location="file:///[path]/override1.properties, file:///[path]/override2.properties" properties-ref="defaultProps" />
<bean id="defaultProps" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<array>
<value>classpath:default1.properties</value>
<value>classpath:default2.properties</value>
</array>
</property>
<property name="properties">
<util:properties local-override="true">
<prop key="some.property">some value</prop>
</util:properties>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
这是我使用的一个非常灵活的设置.允许您直接在xml中使用基本默认值,在属性文件中使用默认值,并在另一个属性文件中覆盖.
| 归档时间: |
|
| 查看次数: |
7137 次 |
| 最近记录: |