Spring Boot2.6.0默认禁止循环怎么引用(springboot,开发技术)

时间:2024-05-05 16:30:01 作者 : 石家庄SEO 分类 : 开发技术
  • TAG :

    Spring%C2%A0Boot2.6.0%E9%BB%98%E8%AE%A4%E7%A6%81%E6%AD%A2%E5%BE%AA%E7%8E%AF%E6%80%8E%E4%B9%88%E5%BC%95%E7%94%A8

如下代码,ComponentA类注入ComponentB类,ComponentB类注入ComponentA类,就会发生循环依赖的问题,在2.6.0之前,spring会自动处理循环依赖的问题

现在,2.6.0 这个版本已经默认禁止 Bean 之间的循环引用,如果存在循环引用就会启动失败报错:

***************************
APPLICATION FAILED TO START
***************************

Description:

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

┌─────┐
| componentA
↑ ↓
| componentB
└─────┘


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.

整改业务,清理掉所有存在循环引用的 Bean

本文:Spring Boot2.6.0默认禁止循环怎么引用的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:JavaScript的写法技巧有哪些下一篇:

4 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18