---
title: 什么是循环依赖
published: 2025-09-16
description: ''
image: ''
tags: [Spring,循环依赖,Java]
category: 'Java > Spring'
draft: false 
lang: ''
---

# 什么是循环依赖
循环依赖就是指两个或者多个模块，类组件之间互相依赖，形成一个闭环

```java
@Service
public class A {
    @Autowired
    private B b;
}

@Service
public class B {
    @Autowired
    private A a;
}

//或者自己依赖自己
@Service
public class A {
    @Autowired
    private A a;
}

```

就像上面这种情况，就属于循环依赖


