博客
关于我
Spring 如何解决循环依赖的问题
阅读量:123 次
发布时间:2019-02-27

本文共 2472 字,大约阅读时间需要 8 分钟。

Spring IOC????????

????????????bean???????????????????Spring?????????????bean????????????????????????????

?????????

????????????bean???????????????????

  • A??B?B??C?C???A?
  • ??????A?B???????????

?????????

  • ?????????

    • ?????????bean?????bean?????bean??????
    • ???
      public class StudentA {    private StudentB studentB;    public StudentA(StudentB studentB) {        this.studentB = studentB;    }}public class StudentB {    private StudentC studentC;    public StudentB(StudentC studentC) {        this.studentC = studentC;    }}public class StudentC {    private StudentA studentA;    public StudentC(StudentA studentA) {        this.studentA = studentA;    }}
    • ??????Spring???????????????
  • setter????????

    • ??bean????field?setter????????bean?????bean??????
    • ???
      public class StudentA {    private StudentB studentB;    public void setStudentB(StudentB studentB) {        this.studentB = studentB;    }}public class StudentB {    private StudentC studentC;    public void setStudentC(StudentC studentC) {        this.studentC = studentC;    }}public class StudentC {    private StudentA studentA;    public void setStudentA(StudentA studentA) {        this.studentA = studentA;    }}
    • ?????????????Spring???????????????
  • ??????????

    Spring???bean????????????????????????????bean????????????????????????bean???????????????????

    ???????????

  • ?????????????

    • Spring??????????????
      • singletonObjects???????????bean?
      • singletonFactories?????bean????
      • earlySingletonObjects??????????bean?
  • ???????

    • ??????????????????
    • ???
    • ?????????????????
  • ?????????

    • ????????????Spring???????????
  • ?????????

    • ?????Spring IDE?BeanFactoryUtils????????
  • ???????

    • ??????????bean???????????????
  • ??Spring??????????

    Spring??????bean??????????????

  • singletonObjects?

    private final Map
    singletonObjects = new ConcurrentHashMap
    (256);
    • ????????????bean?
  • singletonFactories?

    private final Map
    > singletonFactories = new HashMap
    >(16);
    • ??????bean????
  • earlySingletonObjects?

    private final Map
    earlySingletonObjects = new HashMap
    (16);
    • ???????????bean?
  • ???bean??Spring????singletonObjects???bean??????????bean????????earlySingletonObjects????????????????????????singletonFactories????

    ?????????????

  • ?????????

    • ????????????????????????
  • ???????

    • ????bean???????????????
  • ???????

    • ????????????????bean????????
  • ??????????

    • ????????????????????????bean?
  • ????????????????Spring?????????????????????

    转载地址:http://yxmb.baihongyu.com/

    你可能感兴趣的文章
    SpringBoot(十四)整合MyBatis
    查看>>
    percona-xtrabackup 备份
    查看>>
    Perfect,华为爆出 Redis 宝典,原来 Redis 性能可压榨到极致
    查看>>
    SpringBoot集成OpenOffice实现doc文档转html
    查看>>
    springboot自动扫描添加的BeanDefinition源码解析
    查看>>
    Perl Socket传输(带注释)
    查看>>
    ROS中机器人的强化学习路径规划器
    查看>>