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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:39:52+00:00 2026-06-13T01:39:52+00:00

I am asking this Question in reference to my question: spring singleton scope Spring

  • 0

I am asking this Question in reference to my question:

spring singleton scope

Spring singleton is defined in reference manual as per container per bean.

per container means if we do like:

ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml")
MyBean myobj=(MyBean)context.getBean("myBean"); //myBean is of singleton scope.
MyBean myobj1=(MyBean)context.getBean("myBean");

Beans.xml:

<bean id="myBean" class="MyBean"/>

Then myobj==myobj1 will come out to true.Means both pointing to same instance.

For per bean part of phrase per container per bean i was somewhat confused. Am i right in following for per bean :

If we do like

ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml")
MyBean myobj=(MyBean)context.getBean("myBean"); 
MyBean myobj1=(MyBean)context.getBean("mySecondBean");

Beans.xml:

<bean id="myBean" class="MyBean"/>
<bean id="mySecondBean" class="MyBean"/>

Then myobj==myobj1 will come out to false. Means then they are two different instances?

  • 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-13T01:39:52+00:00Added an answer on June 13, 2026 at 1:39 am

    That is correct.

    If it helps, you can also think of Spring beans as Instances that you would’ve otherwise created manually in your Java code using the constructor.

    By defining the bean in the Spring XML file, that bean (Instance) gets registered with Spring’s App Context and then that instance can be passed around to the other areas of the code.

    By creating a new bean, you are effectively creating a new instance. So potentially you could create any number of beans (Instances) of the same class

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

Sidebar

Related Questions

In asking this question, I'm looking for either better understanding of the situation or
I searched before asking this question. I didn't find an answer probably because I
I am finally asking this question as I have never actually found an answer.
I am asking this question here because it is my understanding that this is
I searched SO before asking this question, I am completely new to this and
No luck asking this question on the AWS forum , so will try my
The aim behind asking this question is to improve my understanding of Java Proxies
I'm asking this question because I have gone through the tutorial posted here: Preventing
I'm asking this question as someone who works for a company with a 70%
The very act of asking this question suggests that my approach to this problem

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.