Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am loading properties file in my Spring WebApplication using PropertyPlaceholderConfigurer as below:

<bean
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:db.properties</value>
                <value>classpath:mail.properties</value>
            </list>
        </property>
    </bean>

Now, I want to override some of the properties from mail.properties, so I created an additional entry in my application-context file reading this post, as follows:

<context:property-placeholder location="file:override.properties"
        order="-1" ignore-unresolvable="true" ignore-resource-not-found="true" />

Then, in my Tomcat Server, in VM Arguments of launch configuration, I supplied additional entry:

-Dexternal.props="/Users/ArpitAggarwal/Desktop/override.properties"

With overridden values for some of the keys I have to override.

But, WebApp is not picking up the values from override.properties. Can anybody help me in figuring out, what I am missing.

Any help will be appreciated. Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
713 views
Welcome To Ask or Share your Answers For Others

1 Answer

What I did to resolve the problem is, replaced the location attribute as ${ext.properties.dir:classpath:}/override.properties, as follows:

<context:property-placeholder
        location="${ext.properties.dir:classpath:}/override.properties" order="-1"
        ignore-unresolvable="true" ignore-resource-not-found="true" />

And supplied ext.properties.dir value from application-server/jvm as:

-Dext.properties.dir=file:/Users/ArpitAggarwal/properties/

Reference: 6-tips-for-managing-property-files-with-spring.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...