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

  • Home
  • SEARCH
  • 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 8840795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:32:52+00:00 2026-06-14T10:32:52+00:00

We have a specific format for our config files, where instead of having multiple

  • 0

We have a specific format for our config files, where instead of having multiple files – ie, dev.properties, uat.properties, prod.properties – we instead have all the values in one file, but separated by prefixes for each environment. For example:

SERVICE_PORT=9800

DEV_SERVICE_PORT=7800

UAT_SERVICE_PORT=6600

We have an existing class (subclass of PropertyPlaceholderConfigurer) that looks up these values, and decides what prefix to add inside resolvePlaceHolder() based on the IP address where it is executing, ie for a certain IP range, use DEV_ prefix, for another, use UAT_ prefix. These values then get passed on to other beans, in some cases using the context xml, and in some using the @Value${} annotation on some bean constructors. The use of the prefixes is transparent, so all other configs will use SERVICE_PORT (in the example)

We want to change this so that instead of using IPs, we will just detect the active Spring Profile. We have a custom ApplicationContextIniitalizer in our web.xml that detects a java System property that indicates our type of environment.

The problem I have is that at the time resolvePlaceHolder() gets called, there doesn’t seem to be any Active Profiles yet! What I”m doing to detect the active profile is:

  1. create an instance of StandardEnvironment
  2. call getActiveProfiles()

(2) always seems to return an empty array. This implies that propertyplaceholder resolution occurs before any Spring profiles are activated. Is this correct??

When does the active profile get set, in relation to other events during Spring context loading, like creating the beans, loading property files, etc?

Is it possible to detect the active profile at the time that resolvePlaceHolder() is called? Should I be extending another class instead?

  • 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-14T10:32:53+00:00Added an answer on June 14, 2026 at 10:32 am

    Beans managed within an ApplicationContext may register to be
    EnvironmentAware or @Inject the Environment in order to query profile
    state or resolve properties directly.

    [Source: Environment javadocs ]

    Don’t create an instance of StandardEnvironment, inject it into your bean!

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

Sidebar

Related Questions

I have an array whose values are all arrays of a specific format that
We currently have a specific format for how our email addresses are defined, based
I have a series of grouped values that follow a specific format and would
I have a regular expression which accept time in a specific format like the
I want to create date with specific format for e.g 03-20-2010 have a format
In my rails 3.1 app, I have specific files that are to be loaded
I have a specific requirement of having a toggling table. By toggling I mean
We have a simple binary file format for caching data in our application (C#
We have an ASP.Net application hosted on our network and exposed to a specific
We have an automated method which takes our in-house report specification files and creates

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.