circular references ☕ Java

The dependencies of some of the beans in the application context form a cycle

Two or more Spring beans depend on each other through constructors, and Spring Boot 2.6+ forbids cycles by default.

Seen on: Java

Meaning

A → B → A cycles can’t be built with constructor injection. Spring prints the cycle; the fix is usually a design change.

Common causes

  • Services injecting each other
  • Configuration classes depending on beans they define

⚡ Quick fix

  1. Extract shared logic into a third bean
  2. Use events or interfaces to decouple
  3. As a last resort, @Lazy on one injection point

Detailed fix by platform

Java

  1. public OrderService(@Lazy PaymentService payments) { … }

How to diagnose

  1. Cycle — Which beans are listed?
  2. Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.