【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博客

前后端联调:跨域问题

相关推荐
mldong2 小时前
六语言引擎实现对比:同构背后的妥协与差异
java·架构
Chester_19999 小时前
CSP202203C.计算资源调度器
开发语言·数据结构·c++·蓝桥杯
EXI-小洲11 小时前
Java 操作 Word:字符串替换、图片插入、动态生成表格与API接口下载
java·开发语言·spring boot·word
会周易的程序员11 小时前
给 PLC 写一个字节码虚拟机:STVM 虚拟机架构设计
开发语言·c++·虚拟机·软plc·iec61131·stvm
机器视觉知识推荐、就业指导11 小时前
为什么老说“纯 Qt 没啥就业市场”?
开发语言·qt
telepan11 小时前
Qt 开发避坑与性能指南:如何优雅、安全地定义全局常量字符串?
开发语言·qt
m0_6952514911 小时前
Qt MaintenanceTool 使用国内镜像加速下载(超详细教程)
开发语言·qt
2601_9619017012 小时前
SpringBoot使用Nacos进行application.yml配置管理
java·spring boot·spring
何以解忧,唯有..12 小时前
LangChain 工具调用(Tool Calling)实战指南
java·前端·langchain
大衛說13 小时前
《Python 从入门到精通》系列总览与学习路线
开发语言·python·学习