栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Springboot注入时成环报错

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Springboot注入时成环报错

A注入B,B注入A,成环报错了

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

   categoryController (field private com.itheima.service.CategoryService com.itheima.controller.CategoryController.service)
┌─────┐
|  categoryServiceImpl (field private com.itheima.service.DishService com.itheima.service.impl.CategoryServiceImpl.dishService)
↑     ↓
|  dishServiceImpl (field private com.itheima.service.CategoryService com.itheima.service.impl.DishServiceImpl.categoryService)
└─────┘


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.


Process finished with exit code 1

解决办法一:spring-boot-start-parent版本过高导致,适当的降一下版本即可解决

解决办法二:在B注入A的时候打上注解@Lazy

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/781115.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号