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 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依赖

<dependency>
   <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
    <exclusions>
        <exclusion>
            <groupId>com.netflix.ribbon</groupId>
            <artifactId>ribbon</artifactId>
        </exclusion>
    </exclusions>
</dependency>

添加依赖

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-loadbalancer</artifactId>
</dependency>

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

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

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

appCarController defined in file [E:\Works\NigleEcology\SERVICE\service-tpm\target\classes\cn\nigle\tpm\api\business\app\car\controller\AppCarController.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:\Works\NigleEcology\SERVICE\service-tpm\target\classes\cn\nigle\tpm\api\modular\setting\maintain\service\impl\MaintainItemServiceImpl.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

相关文章
|
1月前
|
Java
用java实现Client和Server之间的互相通信
本文介绍了如何使用Java实现客户端和服务器之间的通信,包括服务器端创建ServerSocket、接受客户端连接、读取和发送消息,以及客户端创建Socket连接、发送和接收消息的完整过程。
28 0
用java实现Client和Server之间的互相通信
|
2月前
|
Java
flyway报错Caused by: java.lang.NoSuchMethodError: org.flywaydb.core.api.configuration.FluentConfigurat
flyway报错Caused by: java.lang.NoSuchMethodError: org.flywaydb.core.api.configuration.FluentConfigurat
36 2
|
3月前
Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
60 3
|
4月前
|
存储 Java Maven
Maven依赖全爆红,一刷新就JAVA_HOME environment variable is not defined correctlyThis environment variable is
Maven依赖全爆红,一刷新就JAVA_HOME environment variable is not defined correctlyThis environment variable is
|
4月前
|
Java Maven
The JAVA_HOME environment variable is not defined correctly,this environment variable is needed to
The JAVA_HOME environment variable is not defined correctly,this environment variable is needed to
|
4月前
|
easyexcel Java Apache
EasyExcel导入的时候报错Caused by: java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/File
EasyExcel导入的时候报错Caused by: java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/File
342 0
|
6月前
|
存储 Oracle 关系型数据库
实时计算 Flink版操作报错之遇到Caused by: java.sql.SQLException: ORA-44609: CONTINOUS_MINE,该怎么处理
在使用实时计算Flink版过程中,可能会遇到各种错误,了解这些错误的原因及解决方法对于高效排错至关重要。针对具体问题,查看Flink的日志是关键,它们通常会提供更详细的错误信息和堆栈跟踪,有助于定位问题。此外,Flink社区文档和官方论坛也是寻求帮助的好去处。以下是一些常见的操作报错及其可能的原因与解决策略。
|
5月前
|
Java Maven
【已解决】MAC安装maven,The JAVA_HOME environment variable is not defined correctly, this environment
【已解决】MAC安装maven,The JAVA_HOME environment variable is not defined correctly, this environment
310 0
|
6月前
|
JavaScript Serverless API
Serverless 应用引擎操作报错合集之在Serverless 应用引擎中,FC3.0读取response body的时候出现错误提示"Caused by: java.io.IOException: closed"如何解决
Serverless 应用引擎(SAE)是阿里云提供的Serverless PaaS平台,支持Spring Cloud、Dubbo、HSF等主流微服务框架,简化应用的部署、运维和弹性伸缩。在使用SAE过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
159 3