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

相关推荐
Ccjf酷儿2 小时前
C++语言程序设计 (郑莉)第十章 泛型程序设计与C++标准模板库
开发语言·c++
HehuaTang2 小时前
requests 调大并对齐 limits 提升POD高负载场景下性能
java·docker·kubernetes
FreeBuf_2 小时前
利用零宽度字符的隐形JavaScript混淆工具InvisibleJS浮出水面
开发语言·javascript·ecmascript
徐_三岁2 小时前
127.0.0.1 和 localhost 有什么区别?
前端
SuperherRo2 小时前
JAVA攻防-Shiro专题&key利用链&CB1链分析&入口点&调用链&执行地&Class加载
java·shiro·反序列化·cb1链
lsx2024062 小时前
Go 语言指针
开发语言
沛沛老爹2 小时前
Web开发者转型AI:Agent Skills版本控制与管理实战——从Git到AI技能仓库
java·前端·人工智能·git·架构·rag
我命由我123452 小时前
充血模型与贫血模型
java·服务器·后端·学习·架构·java-ee·系统架构
yyt3630458413 小时前
TypeScript { [key: string]: unknown } 索引签名写法和 Record 替代
前端·javascript·vue.js·typescript·ecmascript·es6