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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:42:57+00:00 2026-05-26T18:42:57+00:00

I have a spring map declare in the application context xml like this: <map>

  • 0

I have a spring map declare in the application context xml like this:

<map>
    <entry key="mykey">
       <value>${${env}.userkey}</value>
    </entry> 
</map>

However the value never be substituted by the environment. Is there a way to do this?

Thanks,

Sean

  • 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-26T18:42:58+00:00Added an answer on May 26, 2026 at 6:42 pm

    Does #{systemProperties} support environment variables? What’s about using PropertyPlaceholderConfigurer which does (link)

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
    ">
    
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="classpath:env.properties" />
    </bean>
    
    <util:map id="map">
        <entry key="mykey">
           <value>${${env}.userkey}</value>
        </entry>
    </util:map>
    

    env.properties:

    local.userkey=Me
    

    Unit test:

    package org.test;
    
    import static org.junit.Assert.assertEquals;
    import java.util.Map;
    import javax.annotation.Resource;
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.springframework.test.context.ContextConfiguration;
    import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
    
    @ContextConfiguration
    @RunWith(SpringJUnit4ClassRunner.class)
    public class EnvTest {
    
        @Resource
        private Map<String, String> map;
    
        @Test
        public void testMap() throws Exception {
            assertEquals("Me", map.get("mykey"));
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my spring application context file, I have something like: <util:map id="someMap" map-class="java.util.HashMap" key-type="java.lang.String"
I have something like this: Map<String, String> myMap = ...; for(String key : myMap.keySet())
I have a spring-hibernate application which is failing to map an object properly: basically
I have a map defined like this std::map<some_key_type, std::string::iterator> mIteratorMap; And a huge string
I have code like this: val dm = List[String]() val dk = List[Map[String,Object]]() .....
I have a std::map called 'prompts' which is declared like this: std::map<const int, wstring,
I have an interface for a creaky property-map: interface IPropertyMap { bool Exists(string key);
I have a need to set a collection of name/value pairs inside my application
I have this scenario, can anybody fill the gaps for me? Its like this:
We have a Hibernate/Spring application that have the following Spring beans: <bean id=transactionManager class=org.springframework.orm.hibernate3.HibernateTransactionManager

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.