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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:48:45+00:00 2026-05-26T16:48:45+00:00

My application can run on different environments. I need configure MY data model per

  • 0

My application can run on different environments. I need configure MY data model per environment. The data model is build using Spring beans.

I use Spring 3.0.5, so I cannot conditionally load resources.
I have this:

<bean id="Template1" class="...
..............
</bean>

<bean id="Template2" class="...
..............
</bean>

<bean id="Template3" class="...
..............
</bean>
................

<bean id="Factory" ...>
<propety name="type"><value>${app.type}</value></property>
<property>
 <map>
   <entry key="Temlate1" value-ref="Template1">
   <entry key="Temlate2" value-ref="Template1">
   <entry key="Temlate3" value-ref="Template1">

..................

Real bean I create by factory:

<bean id="real" factory="Factory" factory-method="getInstance"
 <constructor-arg>Factory</.....
 .............
 </bean>

Java code:

class Factory {
private Map<String, Object> templateBeans;

 Object getInstance(String name) {
  return templateBeans.get(name);
 ...........

Is it possible in some way to declare abstract template beans? Because I have very big problem with memory. Does another way exist to instantiate different beans conditionally in Spring before version 3.1? It would be good to use only EL because I don’t have access to the Java code of the beans as they are from a third-party library.

  • 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-26T16:48:45+00:00Added an answer on May 26, 2026 at 4:48 pm

    I haven’t tried this but I fairly sure you could use bean aliases for this.

    Firstly declare all your template beans to lazy so they aren’t instantiated on startup.

    <bean id="lazy" class="com.foo.ExpensiveToCreateBean" lazy-init="true"/>
    

    Then use a bean alias with a variable to point to the real one:

    <alias name="real" alias="${beanForEnvironment}"/>
    

    See my answer here for how to nicely load properties per environment:

    property-placeholder location from another property

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

Sidebar

Related Questions

What I need to do is create a web application that can run inside
Is solr a web application that can run on the same instance as a
I have a delphi (Win32) web application that can run either as a CGI
I have a C#/.NET program that can run both as a console application and
I want to make an console application of c which can run other applications
From What is a .NET Application Domain? : You can run several application domains
how can i run code when an application ends with asp.net mvc ?
Can I run PowerShell scripts in an Silverlight application?
On my system I can't run a simple Java application that start a process.
From Eclipse I can easily run all the JUnit tests in my application. I

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.