问题: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层来解决

相关推荐
nnerddboy5 分钟前
Rust教程03:函数,控制流与所有权
开发语言·后端·rust
小龙报6 分钟前
【优选算法】1.搜索插入位置 2.x的平方根
java·c语言·数据结构·c++·python·算法·蓝桥杯
山荷枝15 分钟前
04-框架--SpringBoot
java·spring boot·后端
linux修理工15 分钟前
内存占用 99% 且 Java 程序较多的优化建议
java·开发语言
weixin_4604435620 分钟前
企业考试系统如何对接OA、钉钉和企业微信?SSO单点登录、组织同步与权限一致性设计
java·开发语言·数据库
Sylvia33.22 分钟前
篮球数据API的技术架构与工程实践:基于火星数据WebSocket实时推送体系
java·python·websocket·网络协议·架构
xywww16823 分钟前
真实后台页实测:Opus 5 看图写前端的可用边界在哪
linux·服务器·前端·数据库·人工智能·gpt
Hi李耶36 分钟前
【LeetCode】15.三数之和
java·算法·leetcode
nnerddboy39 分钟前
Rust教程05:结构体,枚举与模式匹配
开发语言·网络·rust
小小尚@42 分钟前
AE脚本-AE Actions v1.1.8 操作动作记录器
开发语言·前端·javascript·jupyter·postman