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 8926185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:54:27+00:00 2026-06-15T07:54:27+00:00

I want to access some property value passed from JVM in Spring’s applicationContext.xml. One

  • 0

I want to access some property value passed from JVM in Spring’s applicationContext.xml. One way I know to achieve this is by #{systemProperties.myProperty} for some -DmyProperty=xyz according to Spring’s Expression Language feature.

But I am interested in having a default value for each such property that I assign through JVM, in case the user doesn’t set the value from JVM options of the server. How can I achieve this in any context xml file for Spring? Please help.

  • 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-15T07:54:29+00:00Added an answer on June 15, 2026 at 7:54 am

    You can make a bean which takes a map parameter from context with default values and initializes system properties

    <bean class="test.B1">
        <constructor-arg>
            <map>
                <entry key="p1" value="v1" />
                <entry key="p2" value="v2" />
                                     ....
            </map>
        </constructor-arg>
    </bean>
    

    .

    public B1(Map<String, String> defaultProperties) {
        for (Map.Entry<String, String> e : defaultProperties.entrySet()) {
            if (System.getProperty(e.getKey()) == null) {
                System.setProperty(e.getKey()
                        , e.getValue());
            }
        }
    }
    

    B1 definition in the context should be before any bean using #{systemProperties.myProperty} so that properties are initialized first

    UPDATE

    That was about overriding system properties. But if you only need to override Spring placeholders like here

    <bean class="test.B1">
        <property name="prop1" value="${xxx}" />
    </bean>
    

    it’s enough to set property-placeholder’s local-override attr to “true”

    <context:property-placeholder location="classpath:/app.properties" local-override="true" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm importing some XML to C#, and want to be able to access data
Introduction I have some sort of values that I might want to access several
I am writing some data access code and I want to check for potentially
I have a site at xyz.com, for some reasons I want to redirect access
I have some pages that I don't want users to be able to access
I want to access java script's return value , which in is in a
I can define a class with a property to access my ivars from outside
I'm using Spring Roo and want to access a bean within of Controller class
I have a variable x in one class.And I want to access the updated
Possible Duplicate: Dynamic object property name I want to dynamically generate access to an

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.