简体   繁体   English

澄清Spring上下文:属性占位符局部重写用法

[英]Clarifying Spring context:property-placeholder local-override usage

I'm using a local override to specify a property and wanted to confirm that this just applies to properties that are specified in the applicationContext. 我正在使用本地替代来指定属性,并想确认这仅适用于applicationContext中指定的属性。 Basically I want to make sure that this doesn't have any unexpected consequences... 基本上我想确保这不会有任何意外的后果...

<context:property-placeholder
    properties-ref="defaultProperties"
    location="classpath:my.properties"
    ignore-resource-not-found="true"
    ignoreunresolvable="true"
    local-override="true"/>

<util:properties id="defaultProperties">
    <prop key="some.property">${overriding.property}</prop>
</util:properties>

No properties except ${some.property} will be overridden, yes? 除$ {some.property}以外的任何属性都不会被覆盖,是吗?

No properties except ${some.property} will be overridden with below code: 除$ {some.property}外的所有属性都不会被以下代码覆盖:

<context:property-placeholder  properties-ref="defaultProperties" location="classpath:my.properties, "ignore-resource-not-found="true" ignoreunresolvable="true" local-override="true"/> 

<bean id="defaultProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
    <util:properties local-override="true">
        <prop key="some.property">${overriding.property}</prop>
    </util:properties>
</property>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM