Durgesh gupta
Durgesh gupta

Reputation: 41

after upgrading the Spring boot version to 2.6, getting circular dependency error

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

Answers (1)

Sumit
Sumit

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

Related Questions