Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于循环依赖 #24

Open
dajiao918 opened this issue Nov 30, 2021 · 6 comments
Open

关于循环依赖 #24

dajiao918 opened this issue Nov 30, 2021 · 6 comments

Comments

@dajiao918
Copy link

我想问一下博主,如果当两个prototype类型的对象互相引用的话,循环依赖是不是还存在呢?我感觉您的代码只能解决单例的循环依赖

@dajiao918
Copy link
Author

当然,我还没看到高级篇,才看到了Aware这里

@DerekYRC
Copy link
Owner

DerekYRC commented Dec 1, 2021

prototype

不用考虑prototype类型bean的循环依赖

@DerekYRC DerekYRC closed this as completed Dec 1, 2021
@DerekYRC DerekYRC reopened this Nov 24, 2022
@DerekYRC
Copy link
Owner

@dajiao918 prototype类型的对象不存在循环依赖的问题,因为每次都容器中获取的prototype类型对象都是新new出来的,不是同一个对象

@wangxinyuanUESTC
Copy link

你好 博主,想问下循环依赖的问题,我把Car对象也增加了一个Person属性,如图
image然后执行
ApplicationContextTest单测,发现会有栈溢出异常,好像还是属性注入的时候死循环了,这种是我操作不对还是代码里其实还没解决循环依赖的问题?求教
image

@wangxinyuanUESTC
Copy link

不好意思,我在Spring.xml里改了Bean配置,如图所示
image
应该就是因为这个配置导致属性赋值的时候栈溢出了

@DerekYRC
Copy link
Owner

@wangxinyuanUESTC 还有问题吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants