问题:Spring循环依赖问题排查与解决

今天写代码遇到的问题

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.

2026-01-16 23:10:59.793 main ERROR o.s.b.diagnostics.LoggingFailureAnalysisReporter-

***************************

APPLICATION FAILED TO START

***************************

Description:

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

clazzController (field private com.itheima.service.ClazzService com.itheima.controller.ClazzController.clazzService)

┌─────┐

| clazzServiceImpl (field private com.itheima.service.StudentService com.itheima.service.impl.ClazzServiceImpl.studentService)

↑ ↓

| studentServiceImpl (field private com.itheima.service.ClazzService com.itheima.service.impl.StudentServiceImpl.clazzService)

└─────┘

Action:

Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.

Disconnected from the target VM, address: '127.0.0.1:14901', transport: 'socket'

Process finished with exit code 1

最后一顿排查是因为循环依赖了,就是A依赖B,B又依赖A,导致项目起不起来

解决方法就是修改依赖,比如service调用mapper层来解决

相关推荐
折哥的程序人生 · 物流技术专研6 小时前
Java面试85题图解版 · 特别篇:2026后端高频面试题复盘(算法底层逻辑+高并发架构设计全解析,附Java实战代码)
java·网络·数据库·算法·面试
问心无愧05136 小时前
ctf show web入门160 161
前端·笔记
xxie1237946 小时前
return与print
开发语言·python
秋96 小时前
从 Python 后端工程师转型 AI Engineer(AI 工程化)的完整补课清单(2026实战版)
开发语言·人工智能·python
一条泥憨鱼6 小时前
【Redis】数据类型和常用命令
java·数据库·redis·后端·缓存
李小白666 小时前
第四天-WEB服务器基本原理,IIS服务
运维·服务器·前端
云烟成雨TD7 小时前
Spring AI Alibaba 1.x 系列【78】沙箱(Sandbox)
java·人工智能·spring
程序员二叉7 小时前
【Java】 异常高频面试题精讲 | 易错点+对比总结
java·开发语言·面试
humcomm7 小时前
AI编程时代新前端职位
前端·ai编程
周航宇JoeZhou7 小时前
JB3-9-SpringAI(二)
java·ai·agent·多智能体·调度·智能体·观察