Sky丶Sanigina 2022-04-11 14:34 采纳率: 50%
浏览 90

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

搭建springBootZuul时出现以下异常:
The dependencies of some of the beans in the application context form a cycle:
┌──->──┐
| org.springframework.cloud.netflix.zuul.ZuulProxyAutoConfiguration (field private org.springframework.cloud.netflix.zuul.filters.discovery.ServiceRouteMapper org.springframework.cloud.netflix.zuul.ZuulProxyAutoConfiguration.serviceRouteMapper)
└──<-──┘

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启动类加上以下这段代码解决,
SpringApplication springApplication = new SpringApplication(SpringBootZuulFilterApplication.class);
springApplication.setAllowCircularReferences(Boolean.TRUE);
springApplication.run(args);

但是我不明白是因为哪里导致依赖循环了,serviceRouteMapper这个类也不知道是干嘛用的,请大家指教一下!谢谢

  • 写回答

1条回答 默认 最新

  • 吕布辕门 后端领域新星创作者 2022-04-15 12:10
    关注

    serviceRouteMapper是服务路由用的,参考如下例子

    ServiceRouteMapper mapper = new ModuleServiceMapper();
    DiscoveryClient discoveryClient = mock(DiscoveryClient.class);
    ResponseLinksMapper responseLinksMapper = new ResponseLinksMapper(mapper, discoveryClient);
    when(discoveryClient.getServices()).thenReturn(Collections.singletonList("service-module"));
    responseLinksMapper.fillServices();
    assertEquals("http://localhost:8080/api/service/entity", responseLinksMapper.fixLink("http://service-module/entity"));
    
    评论

报告相同问题?

问题事件

  • 创建了问题 4月11日

悬赏问题

  • ¥20 为什么我写出来的绘图程序是这样的,有没有lao哥改一下
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败