首页 > 其他分享 >解决循环依赖问题,nacos下配置无效

解决循环依赖问题,nacos下配置无效

时间:2023-02-14 10:47:29浏览次数:36  
标签:依赖 jianke service 无效 tree nacos private field com

报错:

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

Description:

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

BProjectController (field private com.jianke.tree.service.BProjectService com.jianke.tree.controller.BProjectController.projectService)

BProjectServiceImpl (field private com.jianke.tree.service.ISysOrganizationTreeService com.jianke.tree.service.impl.BProjectServiceImpl.iSysOrganizationTreeService)
┌─────┐
| sysOrganizationTreeServiceImpl (field private com.jianke.tree.service.BCompanyService com.jianke.tree.service.impl.SysOrganizationTreeServiceImpl.bCompanyService)
↑ ↓
| BCompanyServiceImpl (field private com.jianke.tree.service.ISysOrganizationTreeService com.jianke.tree.service.impl.BCompanyServiceImpl.sysOrganizationTreeService)
└─────┘


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.

解决办法:

提示已经很明确了,直接添加如下到配置文件application.yml或bootstrap.yml中,这里有个坑:nacos下配置无效需要在项目中的yml中配置。

spring:
main:
allow-circular-references: true

 

 

 

 

 

标签:依赖,jianke,service,无效,tree,nacos,private,field,com
From: https://www.cnblogs.com/CarlJohnson9527/p/17118844.html

相关文章

  • maven 工程pom依赖优化及常用命令
    本文为博主原创,转载请注明出处:1.mvndependency:list----列出项目的所有jar包mvndependency:list-Dverbose该命令可以列出项目依赖的所有jar包,-Dverbose参数......
  • 如何理解spring框架中的依赖注入和控制反转?
     ioc,InversionofControl(控制反转),是Spring中的一种设计思想而非技术。我们可以从4个方面理解ioc:①谁控制谁?——Ioc容器控制对象。②控制了什么?——Ioc容器控......
  • 依赖包确认下载
    首先是获取gogetrsc.io/quote/v4gomodtidy然后就可以使用这个外部包packagemainimport( "fmt" "rsc.io/quote/v4")funcmain(){ //fmt.Println("Hello......
  • Spring容器执行bean依赖解析
    源自:https://docs.spring.io/spring-framework/docs/5.2.12.RELEASE/spring-framework-reference/core.html#beans-setter-injectionDependenciesInjectionSpring容器......
  • ubuntu编译mtk依赖
    更新源1、sudoapt-getupdate2、sudoapt-getinstallgccg++build-essentialasciidocbinutilsbzip2gawkgettextgitlibncurses5-devlibz-devpatchflexbis......
  • spring 依赖注入DI(三)
    概念依赖注入(DependencyInjection,DI)。依赖:指Bean对象的创建依赖于容器.Bean对象的依赖资源.注入:指Bean对象所依赖的资源,由容器来设置和装配.Set注入(......
  • nacos配置中心不生效的解决方案
    nacos配置中心不生效的解决方案​​1、问题描述​​​​2、尝试过程​​​​3、解决方案​​1、问题描述  今天在使用​​nacos​​​做配置中心的时候,我新建配置列表之后......
  • 面试难题:Spring AOP循环依赖,如何解决?
    面试难题:SpringAOP循环依赖,如何解决?问:Spring如何解决循环依赖?答:Spring通过提前曝光机制,利用三级缓存解决循环依赖(这原理还是挺简单的,参考:三级缓存、图解循环依赖原......
  • Maven依赖管理
    本文主要记录Maven依赖管理中关于依赖传递和依赖范围的知识Maven项目示例创建3个maven项目,分配依赖log4j1.2.12,1.2.13,1.2.14版本。<!--项目1--><groupId>com.le......
  • 【学习笔记】依赖注入
    依赖注入1.构造器注入默认是无参构造注入,在bean中,对属性是通过set注入有参构造注入,有三种方式都是使用constructor-arg标签来为有参构造的参数赋值直接通过属性名......