0

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?"

James Z
  • 12,209
  • 10
  • 24
  • 44

3 Answers3

2

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 :)

GJohannes
  • 1,408
  • 1
  • 8
  • 14
  • There is a solution of circular dependency by using @Lazy, it's solved my issue, but for the moment I don't know what's the impacts on my code behind of using this – Spartan Apr 13 '22 at 23:14
1

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
Andronicus
  • 25,419
  • 17
  • 47
  • 88
yamany
  • 23
  • 6
0

@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

user3824316
  • 1
  • 1
  • 6
  • Please comment on my answer so that i get a notification ;). You could certainly try your property. I honestly never heard of it before. Let me know about the outcome – GJohannes Apr 13 '22 at 22:27
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 14 '22 at 05:22