Reputation: 41
Spring boot application failed to start after upgrading to 2.6.4 due to circular dependency.
I have two class like this:
class ABC{
@Autowired
PQR pqr;
}
Class PQR{
@Autowired
ABC abc;
}
previously working fine, now getting circular dependency error after upgrading spring boot to 2.6.4
How to resolve this?
Upvotes: 1
Views: 265
Reputation: 407
You can write @Lazy annotation at top of one of the autowire . This will let your spring application compile without any error
Like below:
Class PQR{
@Lazy
@Autowired
ABC abc;
}
Upvotes: 1