Overriding property file using spring

♀尐吖头ヾ 提交于 2019-11-30 10:13:49
<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>

This is a setup I use that is pretty flexible. Allows you to have basic default values directly in the xml, defaults in a properties file and overrides in another properties file.

have you tried

<property name="ignoreResourceNotFound" value="true"/>
<property name="locations">
    <list>
        <value>classpath:default.properties</value>
        <value>classpath:overwrite.properties</value>
    </list>
</property>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!