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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:13:16+00:00 2026-05-26T07:13:16+00:00

When a properties file is used in a Spring ApplicationContext, its properties may be

  • 0

When a properties file is used in a Spring ApplicationContext, its properties may be accessed in this manner: ${someproperty} inside your xml configuration files. But how do you access the same property within your java code without injecting it via xml?

ApplicationContext config

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="myapp.properties" />
    </bean>
    <bean class="my.app.MyClass">
        <property name="foo" value="${someproperty}" />
    </bean>
</beans>

Properties

someproperty=somevalue

Update 1

The actual point of this, is a special case where a unique id for the application is set in the properties file (ez editing by sysadmin). Several of the application classes implement ApplicationContextAware so they have access to the context and to prevent injecting in each class or defining a bean for every class we want an ez property access method. Our app “knowing” about Spring is not an issue in this case.

  • 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-05-26T07:13:16+00:00Added an answer on May 26, 2026 at 7:13 am

    It doesn’t have any sense to access a property, it contradicts the IoC principle, the main aim of the Spring. In additional to other answers, may be you need all properties? In this case there is a PropertiesFactoryBean object which could give you Properties object to have access for all properties.

    The PropertyPlaceholderConfigurer bean is designed to replace placeholders in a spring context. Any other usages are just confusing at least.

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

Sidebar

Related Questions

I'd like to store a properties file as XML. Is there a way to
How can i inject a properties file containing a Map to be used as
I configures my appstrings.properties file which contains strings related to theme used by my
I have a web application that's based on Spring and the application contexts, applicationContext.xml
lately a requirement came up to outsource the database settings out of Spring applicationContext.xml.
I am new to Spring.Net, until now I was defining the xml file where
I have a properties file in java, in which I store all information of
I have a properties file, let say my-file.properties. In addition to that, I have
I'm parsing a properties file to get a list of properties defiend. I want
I have a properties file which currently contains system names and ip addresses. What

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.