search

Home  >  Q&A  >  body text

java - 面试题:Spring容器启动的时候会加载Bean,那么这些Bean会被加载到什么地方?

如题:面试题:Spring容器启动的时候会加载Bean,那么这些Bean会被加载到什么地方?

PHP中文网PHP中文网2810 days ago386

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 09:42:17

    It will be loaded into the JVM memory heap, managed by beanFactory, and the started one may not be loaded...

    --If the Bean is a singleton, it will be loaded at startup by default. If lazy initialization is set,
    --or multiple instances will be loaded as needed (the object is referenced)...

    ================================

    And it should be noted that if the object is obtained through multiple instances, in spring, it controls its memory releasethrough reference counting,
    so when using multiple instances of beans, remember to add references Set null
    For example:
    Bean b = new Bean();

    //When not in use
    b = null;

    reply
    0
  • 迷茫

    迷茫2017-04-18 09:42:17

    They are all placed in BeanFactory

    reply
    0
  • Cancelreply