麻烦说一下方法参数的意思,以及返回的map中储存的是什么!谢谢!

BeanFactoryUtils这个类中的方法
public static Map beansOfTypeIncludingAncestors(ListableBeanFactory lbf,Class type, boolean includeNonSingletons, boolean allowEagerInit) throwsBeansException

慕容708150
浏览 65回答 1
1回答

大话西游666

spring 容器会在启动的时候为DispatcherServlet初始化handlerMapping.// Find all HandlerMappings in the ApplicationContext,// including ancestor contexts.Map matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(context, HandlerMapping.class, true, false);即找到在context里声明的,所有HandlerMapping和其子类的bean. 可以有多个,这些handlerMapping里有顺序声明,可以根据它来排序。public static Map beansOfTypeIncludingAncestors(ListableBeanFactory lbf, Class type)throws BeansException {Assert.notNull(lbf, "ListableBeanFactory must not be null");Map result = new LinkedHashMap(4);result.putAll(lbf.getBeansOfType(type));if (lbf instanceof HierarchicalBeanFactory) {HierarchicalBeanFactory hbf = (HierarchicalBeanFactory) lbf;if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {Map parentResult = beansOfTypeIncludingAncestors((ListableBeanFactory) hbf.getParentBeanFactory(), type);for (Iterator it = parentResult.entrySet().iterator(); it.hasNext();) {Map.Entry entry = (Map.Entry) it.next();String beanName = (String) entry.getKey();if (!result.containsKey(beanName) && !hbf.containsLocalBean(beanName)) {result.put(beanName, entry.getValue());}}}}return result;}参考当中的源码 
打开App,查看更多内容
随时随地看视频慕课网APP