'Spring boot version changes to 2.6.6 from 2.3.4.RELEASE

I have changed the spring boot version to 2.6.6 from 2.3.4.RELEASE because of security vulnerabilities. My application's deployment is failing.

In pom.xml I have changed the version of only springboot. <spring.boot.version>2.6.6</spring.boot.version>

Error Log:

Unsatisfied dependency expressed through field ''; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '': Unsatisfied dependency expressed through field ''; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '': Unsatisfied dependency expressed through field ''; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '': Unsatisfied dependency expressed through field ''; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '': Unsatisfied dependency expressed through field ''; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name '': Requested bean is currently in creation: Is there an unresolvable circular reference?"



Solution 1:[1]

Well the error message states

Requested bean is currently in creation: Is there an unresolvable circular reference?"

Usually spring boot displays the services for which the circularity was detected. I personally had this problem in the past. The dependency injection is not 100% deterministic and some unrelated changes in your project are now ending up in the detection of such an circular dependency. I am guessing that you are using

@Autowired

to inject you dependencies? When using constructor injection such problems are no longer exist Spring @Autowire on Properties vs Constructor

For now you sadly donĀ“t have any other options then to resolve your circular dependency.

If i am wrong here you need to show more of your exception. from what little that we have it is hard to conclude what is going on :)

Solution 2:[2]

@GJohannes The code is tightly coupled and in many places, I am using @Autowired. Instead of this can I use spring.main.allow-circular-references=true

Solution 3:[3]

spring-boot family starting from 2.6.X not allowing circular reference you can add to your properties this line:

spring.main.allow-circular-references=true

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 GJohannes
Solution 2 user3824316
Solution 3 Andronicus