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

import org.springframework.stereotype.Service;
import javax.annotation.Resource;@Service
public class ComponentA {@Resourceprivate ComponentB componentB;}
import org.springframework.stereotype.Service;
import javax.annotation.Resource;@Service
public class ComponentB {@Resourceprivate ComponentA componentA;}

现在,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:main:allow-circular-references: true

处理方案三:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
public class SpringDemoApplication {public static void main(String[] args) {SpringApplication application = new SpringApplication(SpringDemoApplication.class);application.setAllowCircularReferences(Boolean.TRUE);application.run(args);}
}

Spring Boot 2.6.0 新特性默认禁止循环引用相关推荐

  1. Spring Boot 2.3.0 新特性:优雅停机!

    点击上方"方志朋",选择"设为星标" 回复"666"获取新整理的面试文章 前言:关于Spring Boot.Spring Cloud应用的优 ...

  2. Spring Boot 2.3.0 新特性:优雅停机

    点击上方蓝色"程序猿DD",选择"设为星标" 回复"资源"获取独家整理的学习资料! 前言:关于Spring Boot.Spring Clou ...

  3. [WCF 4.0新特性] 默认终结点

    很多WCF的初学者是从之前的Web服务上转移过来的,他们非常怀念.asmx Web服务无配置的服务寄宿方式.你只需要在定义Web服务的时候再表示服务操作的方法上应用WebMethodAttribute ...

  4. Spring Boot 1.5.x新特性:动态修改日志级别

    前天Spring Boot 1.5终于迎来了第一个RELEASE版本:1.5.0,但是由于一个编译依赖问题在第二天直接连击到了1.5.1.该版本的发布包含了超过320位贡献者的奉献.10000多次的代 ...

  5. MySQL8.0新特性——默认使用caching_sha2_password作为身份验证插件

    mysql5.8开始将caching_sha2_password作为默认的身份验证插件 该caching_sha2_password和 sha256_password认证插件提供比mysql_nati ...

  6. mysql sha256函数_MySQL8.0新特性——默认使用caching_sha2_password作为身份验证插件

    mysql5.8开始将caching_sha2_password作为默认的身份验证插件 该caching_sha2_password和 sha256_password认证插件提供比mysql_nati ...

  7. Spring Boot Admin 2.0开箱体验

    2019独角兽企业重金招聘Python工程师标准>>> 概述 在我之前的 <Spring Boot应用监控实战> 一文中,讲述了如何利用 Spring Boot Admi ...

  8. Spring Boot学习总结(12)——Spring Boot Admin 2.0应用监控示例

    Spring Boot Admin 2.0新特性 Spring Boot Admin 2.0 变化还是挺多的,具体参考 官网说明,这里列几条主要的:使用Vue.js重写了UI界面,漂亮得不像实力派 : ...

  9. [WCF 4.0新特性] 标准终结点与无(.SVC)文件服务激活

    今天介绍WCF 4.0的另外两个新特性:标准终结点(Standard Endpoint)和无(.SVC)文件服务激活(File-Less Activation).前者实现了针对典型通信场景对终结点的定 ...

最新文章

  1. java swing 组件渲染过程_Java Swing无法正确渲染
  2. thinkpad重装系统不引导_thinkpad重装系统不引导_联想电脑重装系统无法引导原因及解决方法...
  3. 服务管理--systemctl命令
  4. 在哪里能收到python实例代码-python下10个简单实例代码
  5. PyTorch系列入门到精通——生成对抗网络一瞥
  6. Mask rcnn介绍
  7. 小猿圈分享Javascript技巧(下)
  8. paip..net代码生成器使用总结
  9. 前端开发学习要装哪些电脑软件
  10. 分库分表:应用场景、方式方法、面临问题
  11. Java 解析pdf文档内容实战案例
  12. linux 找不到vmdk,找不到文件vmdk虚拟磁盘
  13. 高阶篇:4.2.5)DFMEA建议措施及后续完备
  14. MAC地址克隆有什么作用
  15. 同一包(package)下,两个不同类的调用操作详解
  16. mysql 参数 分隔符_mysqldump命令备份多个数据库时,参数之间分隔符是
  17. js与php与mysql_PHP、MySQL和JavaScript入门经典(第6版)
  18. 服务器文件防止被扒,防止别人扒自己的网页方法
  19. HDF文件(.h5)的写入与读取
  20. 2021年全球望远镜收入大约1161.6百万美元,预计2028年达到1275百万美元

热门文章

  1. 网工中级HDLC和PPP
  2. 为什么自考计算机只能4月和10月考试,自学考试2019年一年是只有4月和10月进行考试吗...
  3. yii2程序执行流程:
  4. 【C#】 软件打包与制作安装向导(打包成自解压和打包成安装程序)
  5. 机器视觉之硬件之光学知识
  6. vue 展示本地图片三种方法
  7. 海外社交媒体营销有什么优势?该如何去做?
  8. python高斯核函数运用_高斯核函数
  9. AI智慧安监EasyCVR平台使用时CPU占用与实际使用不符是什么原因?
  10. 计蒜客T1249——漂亮的字符串