@[toc]
前因
这俩天闲来无事想搭建一套最新版本的微服务,顺便写博客记录一下,我用的是当前时间(2022-04-14)最新版本
报错内容
Description:
The dependencies of some of the beans in the application context form a cycle:
com.alibaba.cloud.dubbo.autoconfigure.DubboLoadBalancedRestTemplateAutoConfiguration (field private com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository com.alibaba.cloud.dubbo.autoconfigure.DubboLoadBalancedRestTemplateAutoConfiguration.repository)
↓
com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository (field private com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy com.alibaba.cloud.dubbo.metadata.repository.DubboServiceMetadataRepository.dubboMetadataConfigServiceProxy)
↓
com.alibaba.cloud.dubbo.service.DubboMetadataServiceProxy
┌─────┐
| com.alibaba.cloud.dubbo.autoconfigure.DubboMetadataAutoConfiguration (field private com.alibaba.cloud.dubbo.metadata.resolver.MetadataResolver com.alibaba.cloud.dubbo.autoconfigure.DubboMetadataAutoConfiguration.metadataResolver)
└─────┘
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.
- 翻译
不鼓励依赖循环引用,默认情况下禁止使用循环引用。更新应用程序以消除bean之间的依赖循环。作为最后手段,通过设置弹簧,可能会自动中断循环。主要的允许循环引用true。
解决方案
application.properties
spring.main.allow-circular-references=true
不知道是为什么会出现这个错误,暂时只能先这么设置