V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
tulong
V2EX  ›  Java

Spring 中被 @Autowired 注解的属性取出时机?

  •  
  •   tulong · 2020-04-28 15:24:55 +08:00 · 2249 次点击
    这是一个创建于 1460 天前的主题,其中的信息可能已经有所发展或是发生改变。

    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#populateBean,这个方法我只看到了将 field 和 method 放到了 injectionMetadataCache 缓存起来,包括需要依赖的 bean 实例化存入了 member 中,但是只是通过 beanName 关联被注入的信息,那么怎么取的呢?比如某个类注入了 a,调用 a.hello()方法,那么 a 的获取逻辑是什么?

    2 条回复    2020-04-28 16:41:52 +08:00
    tulong
        1
    tulong  
    OP
       2020-04-28 16:25:06 +08:00
    找到了,少看了这个的逻辑导致后面接不上。。。
    currElements.add(new AutowiredFieldElement(field, required));
    securityCoding
        2
    securityCoding  
       2020-04-28 16:41:52 +08:00
    注入的 bean 本身也是一个类的普通属性, 本身有 类型 /名称属性
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1052 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 18:32 · PVG 02:32 · LAX 11:32 · JFK 14:32
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.