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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:28:37+00:00 2026-05-26T09:28:37+00:00

I have a SimpleObject class public class SimpleObject { public SimpleObject() { Console.WriteLine(Instantiated); }

  • 0

I have a SimpleObject class

public class SimpleObject
{
    public SimpleObject()
    {
        Console.WriteLine("Instantiated");
    }
}

and a simple Spring configuration:

<object id="simpleObject" type="SpringTest.SimpleObject, SpringTest"  />

When I parse the configuration to get the context in order to pass it to my object factory with:

_context = (IApplicationContext)ConfigurationManager.GetSection("spring/context");

I realize that my SimpleObject is instantiated. It sounds like a weird behavior to me. It is normal ? How can I avoid that ? I only want my object to be created when I explicitly ask _context to create one.

  • 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-26T09:28:38+00:00Added an answer on May 26, 2026 at 9:28 am

    I saw you found a configuration that works for you … but here’s an answer to the “why” part of your question.

    By default, an object has singleton scope. Spring instantiates singletons when constructing the container. According to the docs this is done so configuration problems are detected as early as possible, namely at container construction time.

    You can override this default behavior in the object definition by specifying lazy-init="true". Then the singleton will be created when it is first requested on the container, or when it is first needed to construct another object.

    Note that you can also use …

    <objects default-lazy-init="true">
      <!-- no objects will be pre-instantiated... -->
    </objects>
    

    … to let lazy initialization default to true for all objects in the container.

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

Sidebar

Related Questions

I have a simple object public class SomeObject { public Int32 id { get;
If I have a simple object: class MyObject { public string MyValueProperty { get;
Say I have a simple object such as class Something { public int SomeInt
I have a simple object as such: public class Info { public string Name
I have a very simple object called CellData. Is defined as: public sealed class
I have a simple object: [DataContract] public class MyClass { [DataMember(Name = MyClassNo)] public
I have a simple object like this public class Test { public string Name
I have a simple object that get's geocoding data from the Google Maps API
I have a sample class: class SampleClass { public virtual string SomeProperty{get; set;} public
I've got a very simple object: public class DocumentType { private int id; private

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.