栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Caused by: java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forge

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Caused by: java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forge

工具最后日志标注一下错误,或者包含其中错误内容:

        Caused by: java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer?

由于Spring Cloud Feign在Hoxton.M2 RELEASED版本之后不再使用Ribbon而是使用spring-cloud-loadbalancer,所以不引入spring-cloud-loadbalancer会报错.

解决方法:
加入spring-cloud-loadbalancer依赖 并且在nacos中排除ribbon依赖,不然loadbalancer无效

排除ribbon依赖


   com.alibaba.cloud
    spring-cloud-starter-alibaba-nacos-discovery
    
        
            com.netflix.ribbon
            ribbon
        
    


添加依赖


    org.springframework.cloud
    spring-cloud-loadbalancer


如果还是没有解决,请去官方查阅框架对应的版本,实在不行将spring boot和spring cloud的来版本全部降下

注意:最新版本添加依赖后,可能会出现一下错误,循环调用

Description:

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

   appCarController defined in file [E:WorksNigleEcologySERVICEservice-tpmtargetclassescnnigletpmapibusinessappcarcontrollerAppCarController.class]
      ↓
   appCarServiceImpl (field cn.nigle.tpm.api.modular.setting.maintain.service.MaintainMileageItemService cn.nigle.tpm.api.business.app.car.service.AppCarServiceImpl.maintainMileageItemService)
      ↓
   maintainMileageItemServiceImpl (field private cn.nigle.tpm.api.modular.setting.category.service.CategoryDataService cn.nigle.tpm.api.modular.setting.maintain.service.impl.MaintainMileageItemServiceImpl.categoryDataService)
      ↓
   categoryDataServiceImpl (field private cn.nigle.tpm.api.modular.setting.maintain.service.MaintainItemService cn.nigle.tpm.api.modular.setting.category.service.impl.CategoryDataServiceImpl.maintainItemService)
      ↓
   maintainItemServiceImpl defined in file [E:WorksNigleEcologySERVICEservice-tpmtargetclassescnnigletpmapimodularsettingmaintainserviceimplMaintainItemServiceImpl.class]
      ↓
   attrService (field cn.nigle.tpm.api.modular.product.service.CategoryService cn.nigle.tpm.api.modular.product.service.impl.AttrServiceImpl.categoryService)
      ↓
   categoryService (field cn.nigle.tpm.api.modular.product.service.CategoryBrandRelationService cn.nigle.tpm.api.modular.product.service.impl.CategoryServiceImpl.categoryBrandRelationService)
┌─────┐
|  categoryBrandRelationService (field cn.nigle.tpm.api.modular.product.service.ProductBrandService cn.nigle.tpm.api.modular.product.service.impl.CategoryBrandRelationServiceImpl.brandService)
↑     ↓
|  brandService (field cn.nigle.tpm.api.modular.product.service.CategoryBrandRelationService cn.nigle.tpm.api.modular.product.service.impl.ProductBrandServiceImpl.categoryBrandRelationService)
└─────┘


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.


可在配置文件中设置:

spring.main.allow-circular-references = true.

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/826221.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号