知识卡片

普通读书笔记卡 · 1908.d.4

复用容器发现避免重复扫描

理解等级:中级

当扩展实现本来就是Spring管理的Bean时,可以通过ListableBeanFactory.getBeansWithAnnotation获取带指定注解的Bean,复用容器已有的发现结果。COLA 3.0据此移除原来独立的扫描方案。Bean查询与扫描任意类路径并不相同,未进入该容器的类不能仅因带注解就假设会被发现。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      getBeansWithAnnotation()方法,另一种方式是使用ClassPathScanningCandidateComponentProvider进行扫包。 在这次改版中,我选用了ListableBeanFactory.getBeansWithAnnotati

    参考来源

    - 位置:《程序员的底层思维》第18章《COLA的演进过程》(来源项目book-sources,`extracted/程序员的底层思维/_epub-src/Cheng Xu Yuan De Di Ceng Si Wei_split_024.html`)。 - 结论依据:原文从“getBeansWithAnnotation()方法,另一种方式”展开,与本卡的“当扩展实现本来就是Spring管理的Bean时,可以通过ListableBeanFactory.getBeansWithAnnotation获取带指定注解的Bean,复用容器已有的发现结果”对应;正文额外解释的限制、反例或外部校正均不冒充原书保证。 - 原始内容:getBeansWithAnnotation()方法,另一种方式是使用ClassPathScanningCandidateComponentProvider进行扫包。 在这次改版中,我选用了ListableBeanFactory.getBeansWithAnnotati