I want to resolve a circular dependency with it.
I am aware that there is a drawback of this annotation namely in case of a bean misconfiguration the error will come to the surface only at invocation time:
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/Lazy.html
"Please note that such a lazy-resolution proxy will always be injected; if the target dependency does not exist, you will only be able to find out through an exception on invocation. As a consequence, such an injection point results in unintuitive behavior for optional dependencies."
My question is this really a drawback in any sense if I already use the given bean as non-lazy singleton at other parts of application? Which basically proves that the bean itself can be created.
example:
@Component
class A {
@Autowired
private B b;
}
@Component
class B {
@Autowired
@Lazy
private A a;
}
@Component
class C {
@Autowired
private A a; <- this is the evidence that the bean can be created so it wont fail when injecting it into classB when invoked
}