Spring boot:循环依赖(The dependencies of some of the beans in the application context form a cycle)

笔记(此次问题忘记截图):运行过程提示说(应用程序上下文中某些bean的依赖关系形成一个循环)

出现如下描述:

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

   todoController (field private com.xm.service.TodoService com.xm.controller.TodoController.todoService)
┌─────┐
|  todoService (field private com.xm.service.TodoService 

com.xm.service.TodoService.todoMapper)

注意:它会提供处理方法(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.

 不支持依赖循环引用,在默认情况下是禁止的,可以在配置文件中(application.yml)进行设置

spring.main.allow-circular-references: true

如图:

猜你喜欢

转载自blog.csdn.net/qq_47229902/article/details/123639801