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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:17:25+00:00 2026-06-16T17:17:25+00:00

I am confused about the lifecycle of Spring. XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource(SpringHelloWorld.xml));

  • 0

I am confused about the lifecycle of Spring.

XmlBeanFactory beanFactory 
= new XmlBeanFactory(new ClassPathResource("SpringHelloWorld.xml"));

Whether the above snippet of codes creates the object or not?

If the above answer is true.

a) Then, for the bean where scope is “singleton” get the object which was created during the above snippet of code. Am i right or wrong?

b) For the case where scope is “prototype”, whether the created object was unused. Because, the container always return new object.

XmlBeanFactory beanFactory 
= new XmlBeanFactory(new ClassPathResource("SpringHelloWorld.xml"));

Whether the above snippet of codes creates the object or not?

If the answer is false,

How the spring framework validates whether the bean definition is correct or not.

From the answer of Henry

Usually, singleton beans are created when the context starts. This can be changed with the lazy-init or default-lazy-init attributes.

Prototype beans are only created when needed.

Only syntactically, there might still be errors when the bean is instantiated, for example if a required property is not provided.

  • 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-16T17:17:26+00:00Added an answer on June 16, 2026 at 5:17 pm

    BeanFactory does not pre-instantiate singletons on startup like ApplicationContext does. So even if your bean is non-lazy and singleton, it won’t be created.

    prototype beans are created on demand, every time you ask for a prototype bean you’ll get a new instance. But once such bean was used during autowiring, the same instance will be used forever.

    With ApplicationContext all singletons are created eagerly and prototype beans only on demand.

    See also

    • BeanFactory vs ApplicationContext
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm somewhat confused about the lifecycle of ManagedBeans of type request. In this example
I am confused about Service lifecycle. I have many questions following: If my app
At the moment I'm a little bit confused about the lifecycle management in Android.
I am a little confused about Accept-Encoding . I have Web Service which would
I am a little confused about the roles of a java application server and
I'm a bit confused about the size of my App! The folder and all
I am a bit confused about the 'rules' of when a TextView element displays
I'm a little confused about something. I wrote an app and tested it on
I'm a little confused about the HTTP protocol, from what i know HTTP was
I am a little confused about where to use strong and where to use

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.