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

前后端联调:跨域问题

相关推荐
LYOBOYI12312 小时前
qt的事件传播机制
java·前端·qt
PM老周12 小时前
产品路线图怎么做:从愿景到里程碑的 6 步落地法
开发语言·安全·阿里云·团队开发·个人开发
短剑重铸之日12 小时前
《深入解析JVM》第四章:JVM 调优
java·jvm·后端·面试·架构
whltaoin12 小时前
25年12月26日-福州某科技公司一面面试原题
java·linux·docker·面试·职场和发展·k8s·springboot
小陈phd12 小时前
Python MCP 工具开发入门:Server、Client 和 LLM 集成
开发语言·python·github
Yang-Never12 小时前
Android 内存泄漏 -> ViewModel持有Activity/Fragment导致的内存泄漏
android·java·开发语言·kotlin·android studio
剑之所向12 小时前
c# 中间表
开发语言·c#
fanruitian13 小时前
SpringBoot 调用springai ollama
java·spring boot·后端
蓝影铁哥13 小时前
浅谈5款Java微服务开发框架
java·linux·运维·开发语言·数据库·微服务·架构
程芯带你刷C语言简单算法题13 小时前
Day39~实现一个算法确定将一个二进制整数翻转为另一个二进制整数,需要翻转的位数
c语言·开发语言·学习·算法·c