title: Dependency injection in Spring
body: <p>I am trying to understand how Dependency Injection works. I am reading Pro Spring 2.5 and have gotten to chapter 3. Some questions that has come to my mind is:</p>
  
  <p>When you make the bean factory in the main method of your stand alone application (it would be interesting to know in a web app too) and then read the bean configuration file, what happens then?
  Does it create the beans with their dependencies at that point and keeps those in a register or is it just the configuration information it keeps in the register?</p>
  
  <p>I understand that you should try to keep dependency lookup to a minimum so if you have a MyApplication class or something that bootstraps the application that is preferred. Now, how would Spring or the POJO's know where and when to inject the dependencies if the factory with the register is only available in the main method? Isn't the register only available in the main method? Since you are not calling "getBean(...)" anymore where does the constructing take place? How does it manage to keep the beans as singletons etc?</p>