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