循环依赖(A--->B,B--->A)
-
构造方法的循环(无法解决)
-
public A{ private B b; public A(B b){ this.b=b; } } public B{ private A a; public B(A a){ this.a=a; } }
-
set方法的循环(spring中可以通过缓存去解决掉)
-
public class A{ private B b; public setA(B b){ this.b=b; } } public class B{ private A a; public setB(A a){ this.a=a; } }