您好,登錄后才能下訂單哦!
public?interface?BeanFactory?{ ???String?FACTORY_BEAN_PREFIX?=?"&"; ???/** ????*? ????*/ ???Object?getBean(String?name)?throws?BeansException; ???/** ????*? ????*/ ???<T>?T?getBean(String?name,?@Nullable?Class<T>?requiredType)?throws?BeansException; ???/** ????*? ????*/ ???Object?getBean(String?name,?Object...?args)?throws?BeansException; ???/** ????*? ????*/ ???<T>?T?getBean(Class<T>?requiredType)?throws?BeansException; ???/** ????*? ????*/ ???<T>?T?getBean(Class<T>?requiredType,?Object...?args)?throws?BeansException; ???/** ????*? ????*/ ???boolean?containsBean(String?name); ???/** ????*? ????*/ ???boolean?isSingleton(String?name)?throws?NoSuchBeanDefinitionException; ???/** ????*? ????*/ ???boolean?isPrototype(String?name)?throws?NoSuchBeanDefinitionException; ???/** ????*? ????*/ ???boolean?isTypeMatch(String?name,?ResolvableType?typeToMatch)?throws?NoSuchBeanDefinitionException; ???/** ????*? ????*/ ???boolean?isTypeMatch(String?name,?@Nullable?Class<?>?typeToMatch)?throws?NoSuchBeanDefinitionException; ???/** ????*? ????*/ ???@Nullable ???Class<?>?getType(String?name)?throws?NoSuchBeanDefinitionException; ???/** ????*? ????*/ ???String[]?getAliases(String?name); }
getBean
重載了(overload)5個getBean方法:可分為1.按照name獲取bean。2.按照type獲取bean。
其中getBean(String name,Object... args)與getBean(Class<T> requiredType,Object... args)方法需要注意后面的參數Object是構造方法的參數。另外bean的scope(bean在IOC容器中的生命周期)需要配置為prototype。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。