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

相关推荐
野生风长5 分钟前
c++类和对象(this指针,重载operator,习题总结)
java·开发语言·c++
恋猫de小郭7 分钟前
Flutter 3D 渲染的全新选择和应用场景
android·前端·flutter
霸道流氓气质15 分钟前
基于 Spring 事务同步机制的事务后置动作收集器 Starter 实践
java·后端·spring
IT_陈寒17 分钟前
Java线程池踩了个坑,任务居然默默消失了
前端·人工智能·后端
过期动态21 分钟前
【LeetCode 热题 100】找到字符串中所有字母异位词
java·数据结构·算法·leetcode·职场和发展·rabbitmq
程序员爱钓鱼1 小时前
配置 GoLand 与 VS Code 开发环境
前端·后端·go
皓月斯语1 小时前
程序设计语言的特点
开发语言·数据结构·c++
程序员爱钓鱼1 小时前
Rust Vec 动态数组详解:创建、增删、遍历与排序
前端·后端·rust
超人不会飞_Jay1 小时前
Go课程2
开发语言·后端·golang
刘小八1 小时前
Spring AI Tool Calling 生产化:参数校验、权限控制与超时隔离
java·人工智能·spring