340_依赖循环引用Relying upon circular references is discouraged and they are prohibited by default

报错信息

image.png

15:21:53.398 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter - [report,40] - 

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

Description:

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

   tokenController (field private com.ruoyi.auth.service.SysLoginService com.ruoyi.auth.controller.TokenController.sysLoginService)
      ↓
   sysLoginService (field private com.ruoyi.system.api.RemoteLogService com.ruoyi.auth.service.SysLoginService.remoteLogService)
      ↓
   org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration
┌─────┐
|  com.alibaba.cloud.sentinel.SentinelWebAutoConfiguration (field private java.util.Optional com.alibaba.cloud.sentinel.SentinelWebAutoConfiguration.sentinelWebInterceptorOptional)
└─────┘

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.

15:21:54.055 [Thread-3] WARN  c.a.n.c.h.HttpClientBeanHolder - [shutdown,108] - [HttpClientBeanHolder] Start destroying common HttpClient
15:21:54.056 [Thread-8] WARN  c.a.n.c.n.NotifyCenter - [shutdown,136] - [NotifyCenter] Start destroying Publisher
15:21:54.056 [Thread-8] WARN  c.a.n.c.n.NotifyCenter - [shutdown,153] - [NotifyCenter] Destruction of the end
15:21:54.056 [Thread-3] WARN  c.a.n.c.h.HttpClientBeanHolder - [shutdown,114] - [HttpClientBeanHolder] Destruction of the end
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。  

解决

image.png

spring:
  main:
    allow-circular-references: true
# Tomcat
server: 
  port: 9200

# Spring
spring:
  application:
    # 应用名称
    name: ruoyi-auth
  profiles:
    # 环境配置
    active: dev
  cloud:
    nacos:
      discovery:
        # 服务注册地址
        server-addr: 172.16.0.246:8848
      config:
        # 配置中心地址
        server-addr: 172.16.0.246:8848
        # 配置文件格式
        file-extension: yml
        # 共享配置
        shared-configs:
          - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
  main:
    allow-circular-references: true
posted @ 2024-03-20 09:57  清风(学习-踏实)  阅读(1)  评论(0编辑  收藏  举报