【java后端开发问题合集】

大家如果有开发上问题可以私信我,我会发布解决文章在里面。

循环依赖

当出现这样的报错信息,说明我们的项目出现了循环依赖。

复制代码
***************************
APPLICATION FAILED TO START
***************************

Description:

The dependencies of some of the beans in the container form a cycle:

┌─────┐
|  serviceA defined in file [com/example/ServiceA.class]
↑     ↓
|  serviceB defined in file [com/example/ServiceB.class]
└─────┘

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.

实际举例

我们有class a , class b, class c.

复制代码
import org.springframework.stereotype.Component;
import org.springframework.beans.factory.annotation.Autowired;

@Component
public class ClassA {
    
    @Autowired  // 构造器注入
    private ClassB b;

}


@Component
public class ClassB {
    
    @Autowired  // 构造器注入
    private ClassC c;

}


@Component
public class ClassC {
    
    @Autowired  // 构造器注入
    private ClassC c;

}

这三类相互依赖,让我们的程序报错。解决方法如下。

彻底搞懂Java后端循环依赖:Spring解决原理+实战避坑指南(面试高频)-CSDN博客

前后端联调:跨域问题

相关推荐
keyipatience40 分钟前
线程栈与TLS和线程互斥
java·linux·服务器·开发语言·ubuntu
我的xiaodoujiao1 小时前
快速学习Python基础知识详细图文教程9--函数进阶
开发语言·python·学习·测试工具
weixin_408099671 小时前
2026 图片去水印 API 接口完全指南:一键去除图片水印(附 Python/Java/PHP/C# 示例)
java·python·php·图片处理·api调用·图片去水印·石榴智能
爱喝水的鱼丶1 小时前
SAP-ABAP:ALV通用封装实践——搭建可复用的ALV开发工具类,减少80%重复代码
开发语言·性能优化·sap·abap·erp·alv
钱六两2 小时前
#3、SpringAI 接入deepSeek大模型(喂饭版)
java·spring boot·ai编程
脱胎换骨-军哥2 小时前
C++/Rust无缝互操作:混合系统新常态
开发语言·c++·rust
songroom2 小时前
Kimi K3:Rust封装XTP接口详细教程实践
开发语言·后端·rust
kebeiovo2 小时前
游戏服务端开发:Actor模型详解(Go语言)
开发语言·后端·golang
迷途呀2 小时前
Python:函数中的参数类型
开发语言·笔记·python·langchain·nlp
null_173 小时前
IntelliJ IDEA 极致流畅配置方案:Ultra 9 285K + 64GB 内存实测
java·ide·intellij-idea