Spring Bean循环引用如何简单识别?
- 内容介绍
- 文章标签
- 相关推荐
本文共计392个文字,预计阅读时间需要2分钟。
看了一次Spring公开课,记录一下bean的循环引用问题。
问题:在以下实例中,IndexService依赖IndexDao,而IndexDao又依赖IndexService,形成循环依赖。
javapublic class IndexService { @Autowired IndexDao indexDao;}
public class IndexDao { @Autowired IndexService indexService;}
看过一次spring公开课,记录一下bean的循环引用问题。
问题:
public class IndexService{ @Autowired IndexDao indexDao; } public class IndexDao{ @Autowired IndexService indexService; }
以上的实例中IndexService依赖IndexDao,IndexDao中依赖IndexService。
spring在bean的实例化过程:
先去创建IndexDao bean,
1.创建IndexDao实例,此时还没有IndexDao bean产生。
本文共计392个文字,预计阅读时间需要2分钟。
看了一次Spring公开课,记录一下bean的循环引用问题。
问题:在以下实例中,IndexService依赖IndexDao,而IndexDao又依赖IndexService,形成循环依赖。
javapublic class IndexService { @Autowired IndexDao indexDao;}
public class IndexDao { @Autowired IndexService indexService;}
看过一次spring公开课,记录一下bean的循环引用问题。
问题:
public class IndexService{ @Autowired IndexDao indexDao; } public class IndexDao{ @Autowired IndexService indexService; }
以上的实例中IndexService依赖IndexDao,IndexDao中依赖IndexService。
spring在bean的实例化过程:
先去创建IndexDao bean,
1.创建IndexDao实例,此时还没有IndexDao bean产生。

