Recently, a circular-dependency error occurred in the project and I solved it this way, but I did not fully understand how this code works. What exactly did @Lazy annotation do here? Or how did it inject BeanB to form BeanA?
public class BeanA {
private BeanB beanB;
@Autowired
public void setBeanB(BeanB beanB) {
this.beanB = beanB;
}
}
public class BeanB {
private BeanA beanA;
@Autowired
@Lazy
public void setBeanA(BeanA beanA) {
this.beanA = beanA;
}
}
Advance thanks.......