@Scope:设置组件作用域 1.prototype:多例的2.singleton:单例的(默认值)
* @see ConfigurableBeanFactory#SCOPE_PROTOTYPE prototype
* @see ConfigurableBeanFactory#SCOPE_SINGLETON singleton(默认)
* @see org.springframework.web.context.WebApplicationContext#SCOPE_REQUEST request
* @see org.springframework.web.context.WebApplicationContext#SCOPE_SESSION session
prototype ,singleton的bean 创建在ioc 分别在何时调用呢?
singleton 会在ioc容器启动时会调用方法创建对象放入ioc中,以后每次获取直接从容器中获取(map.get())
ApplicationContext context = new AnnotationConfigApplicationContext(MainConfig2.class);
prototype 在getBean获取对象时创建,并且是调用几次创建几次。
Person person = context.getBean( Person.class);