问题: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 分钟前
Claude Code:终端AI编程助手全指南(附带指令全讲解)
开发语言·后端·面试·ai编程
淡笑沐白7 分钟前
JavaScript零基础到精通
开发语言·javascript·ecmascript
Languorous.8 分钟前
C++智能指针详解:原理、使用及避坑指南
开发语言·c++
無名路人9 分钟前
小程序点餐页吸顶滚动
前端·微信小程序·ai编程
老马952713 分钟前
opencode7-桌面应用实战2
java·人工智能·后端
小小小前端啊14 分钟前
前端手写代码大全
前端
广州灵眸科技有限公司19 分钟前
瑞芯微(EASY EAI)RV1126B yolov11-track多目标跟踪部署教程
linux·开发语言·网络·人工智能·yolo·机器学习·目标跟踪
李白的天不白22 分钟前
大规模请求数据并发问题
java·前端·数据库
智慧物业老杨1 小时前
智慧物业数智化转型实战:从工单响应到业主满意度的闭环构建
java·开发语言
Kiling_07041 小时前
Java集合框架:List集合详解与应用
java·开发语言·windows