tulong
V2EX  ›  Java

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

  •  
  •   tulong · Apr 28, 2020 · 3127 views
    This topic created in 2235 days ago, the information mentioned may be changed or developed.

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

    2 replies    2020-04-28 16:41:52 +08:00
    tulong
        1
    tulong  
    OP
       Apr 28, 2020
    找到了,少看了这个的逻辑导致后面接不上。。。
    currElements.add(new AutowiredFieldElement(field, required));
    securityCoding
        2
    securityCoding  
       Apr 28, 2020
    注入的 bean 本身也是一个类的普通属性, 本身有 类型 /名称属性
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2773 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 15:28 · PVG 23:28 · LAX 08:28 · JFK 11:28
    ♥ Do have faith in what you're doing.