Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9153341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:15:28+00:00 2026-06-17T12:15:28+00:00

we were using spring 2.5, we want to add make sure that my properties

  • 0

we were using spring 2.5, we want to add make sure that my properties should be either provided from the environment config_path=C:/application.properties or overrides from default location that is classpath

So we did it as below
applicationcontext.xml

<bean class="com.test.utils.ExtendedPropertySourcesPlaceholderConfigurer">
    <property name="overridingSource" value="file:${config_path}/application.properties"/>
    <property name="locations" value="classpath*:META-INF/*-config.properties" />
</bean>

ExtendedPropertySourcesPlaceholderConfigurer code

public class ExtendedPropertySourcesPlaceholderConfigurer extends PropertySourcesPlaceholderConfigurer implements InitializingBean, ApplicationContextAware {

    private ApplicationContext applicationContext;

    private Resource overridingSource;

    public void setOverridingSource(Resource overridingSource) {
        this.overridingSource = overridingSource;
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        MutablePropertySources sources = ((ConfigurableApplicationContext) applicationContext).getEnvironment().getPropertySources();
        if (overridingSource == null) {
            return;
        }
        sources.addFirst(new ResourcePropertySource(overridingSource));
    }
}

Now we are moving this to spring 3.1.2 and can help me out weather spring has provided some new API to do it more efficient way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:15:29+00:00Added an answer on June 17, 2026 at 12:15 pm

    Spring 3.1 introduced a new Environment Abstraction, PropertySource Abstraction (both links show SpringSource Blog articles).

    But I think you do not need to override it in spring 3.0 or 3.1

    <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath*:application-config.properties</value>
                <value>file:${user_config_path}/application-config.properties</value>
            </list>
        </property>
        <property name="localOverride" value="true" />
        <property name="ignoreResourceNotFound" value="true" />
    </bean>
    

    BTW. in Spring 3.0 the bean class is: PropertyPlaceholderConfigurer (see this blog http://www.baeldung.com/2012/02/06/properties-with-spring/)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to integrate facebook login into my web application developed using Spring MVC.
I am working on profiling a legacy application using Spring AOP and I want
I'm trying to put together a contract-first web application using Spring-WS. I want to
I'm using Hibernate for a Java-based Web Application and want to add full-text search
I am using Spring 3.1 and want to include Spring Web Flow 2.3. One
I am using spring 3.0 webservices. It produces a json response. I want to
I am developing project using Spring , Struts2 & Hibernate . Now I want
I'm using Eclipse/Spring source to edit JSP tags and EL. If I want to
I want to create a rest api using reasteasy and jax-rs in spring. to
If I want to analyze a string using dozens of regular-expressions, could either the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.